简体   繁体   English

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

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

I have attached 2 pictures. 我已附上2张图片。 The iPhone 6 picture is the correct one which should be displayed in all devices. iPhone 6图片是正确的图片,应在所有设备上显示。 Every page should display the page as in the 1st image (that of iPhone6). 每个页面都应按第一张图片(iPhone6的图片)显示该页面。 It is getting distorted in iPhone 5 (image attached), android devices and in tablets 它在iPhone 5(附有图像),Android设备和平板电脑中变得失真

HTML Code ( using AngularJS and ionic) 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 Code 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;
}

I am showing through two pictures how the page is getting distorted for some devices, say for example the code is working perfect for iPhone 6 but getting distorted for say iPhone5. 我通过两张图片显示页面在某些设备上是如何失真的,例如说代码对于iPhone 6来说是完美的,但在iPhone5上却失真了。 This page should work in all mobile and tablet devices 此页面应可在所有移动设备和平板电脑上使用

iPhone 6 iPhone 6

iPhone 5 iphone 5

I have to make it work for all devices like iPhone6 where it is working perfect. 我必须使其能够在所有运行正常的iPhone6等设备上正常运行。 Since this page is mobile only I have not used @Media query. 由于此页面只能移动,因此我没有使用@Media查询。

Consider using the ionic 2 grid system which is specifically created for developing responsive grid layouts. 考虑使用专门为开发响应式网格布局而创建的ionic 2网格系统

In your case you would need something like 在您的情况下,您将需要

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

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

For additional margin and padding you can add some of the ionic 2 css utilities instead of writing up your own css . 为了增加边距和填充,您可以添加一些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