繁体   English   中英

为什么此CSS代码无法在所有设备上正常工作?

[英]Why this CSS code is not working properly in all devices?

我已附上2张图片。 iPhone 6图片是正确的图片,应在所有设备上显示。 每个页面都应按第一张图片(iPhone6的图片)显示该页面。 它在iPhone 5(附有图像),Android设备和平板电脑中变得失真

HTML代码(使用AngularJS和ionic)

<ion-view >
<ion-nav-title>
    <div class="trip-title">Trips</div>
</ion-nav-title>


<ion-content class="aaaaa">

    <ion-tabs class="tabs-striped tabs-top tabs-background-dark tabs-color-energized">

        <ion-tab title="PAST TRIPS" ui-sref="previous" on-select="onPreviousTabSelected()">
        <ion-nav-view name="previous"></ion-nav-view>
        </ion-tab>

        <ion-tab title="UPCOMING TRIPS" ui-sref="future" on-select="onFutureTabSelected()">
            <ion-nav-view name="future"></ion-nav-view> 
        </ion-tab>

    </ion-tabs> 

    <div class="triprepeat" ng-repeat="item in items| orderBy : '-tripDate'">
       <div class="div-box-trip">
           <img class="cartrip" src="http://www.irantravelservice.com/images/icon/car.png" alt="Custom Image"/>
            <span><div class="date-trip">{{item.starRating}}, {{item.tripDate}}</div></span>
             <span><div class="bookingidtitle-trip">Booking Id : </div></span>
             <span><div class="bookingid-trip">{{item.tripId}}</div></span>
             <span>
             <div class="starttime-trip">{{item.tripStartTime}}</div>
             <div>  
                 <img class="arrowright-trip" src="http://worldconflictsresearch.t83.net/communities/8/004/013/145/338//images/4621747970_179x256.png" alt="Custom Arrow Image"/>
              </div>
              </span>
              <span>
              <div class="source-trip">{{item.sourceLocation}}</div>
              <div>
                 <img class="greencircle-trip" src="http://stavangerkarateklubb.no/wp-content/uploads/2016/05/grønn.png" alt="Custom Red Circle"/></div>
              </span>
              <span><div class="dashed-trip"><hr class="dashtrip"/></div></span>
              <span>
              <div class="dest-trip">{{item.destinationLocation}}</div>
              <div><img class="redcircle-trip" src="http://107.6.178.147/wp360/wordpress/wp-content/uploads/2016/04/red.png" alt="Custom Red Circle"/></div>
              </span>
            </div>

       </div>

</ion-content>

CSS代码

.view-container .scroll-content.ionic-scroll.has-header.aaaaa {     
  background-color: #ffffff;      
}

.cartrip{
  max-width: 40px !important;
  margin-top: 15px;
  margin-left: 20px;  
}

.triprepeat{
  background-color: #f1f1f1; 
  border-bottom: solid 1.5px #B2B2B2;
  margin-left: 15px;
  margin-right: 15px;
  margin-top: 10px;
  margin-bottom: 10px;
}

.date-trip{
  margin-left: 80px;
  margin-right: auto;
  margin-top: -50px;
  font-size: 12px;
  color: #000000;
}

.div-box-trip{
  height: 120px;
  width: auto;
}

.bookingidtitle-trip{
  margin-left: 80px;
  margin-top: 8px;
  font-size: 11px;
  color: #A9A9A9;
}

.bookingid-trip{
  margin-left: 160px;
  margin-right: auto;
  margin-top: -20px;
  font-size: 12px;
  color: #000000;
}

.starttime-trip{
  margin-left: 250px;
  margin-right: auto;
  margin-top: -48px;
  font-size: 12px;    
}

.arrowright-trip{
  height: 15px;
  width: auto;
  position: absolute;
  margin-top: -18px;
  margin-left: 315px;
}

.source-trip{
  margin-left: 80px;
  margin-top: 40px;
  font-size: 12px;
  color: #000000;
}

.dest-trip{
  margin-left: 280px;
  margin-top: -32px;
  font-size: 12px;
  color: #000000;
}

.greencircle-trip{
  height: 15px;
  width: 15px;
  margin-left: 85px;
}

.redcircle-trip{
 height: 15px;
  width: 15px;
 margin-left: 295px;    
}

.dashtrip{
  border-top: dotted 1px;
  width: 170px;
}

.dashed-trip{
  margin-left: 110px;
  margin-top: -10px;
}

我通过两张图片显示页面在某些设备上是如何失真的,例如说代码对于iPhone 6来说是完美的,但在iPhone5上却失真了。 此页面应可在所有移动设备和平板电脑上使用

iPhone 6

iphone 5

我必须使其能够在所有运行正常的iPhone6等设备上正常运行。 由于此页面只能移动,因此我没有使用@Media查询。

考虑使用专门为开发响应式网格布局而创建的ionic 2网格系统

在您的情况下,您将需要

<ion-grid>
   <ion-row>
      <ion-col col-2>
          Left Side
      </ion-col>

      <ion-col col-10>
         Right side
      </ion-col>
   </ion-row>
</ion-grid>

为了增加边距和填充,您可以添加一些ionic 2 css实用程序,而不用编写自己的css

 <ion-col col-10 margin-right no-padding>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM