简体   繁体   English

响应式设计-Iphone人像与风景

[英]Responsive design - Iphone portrait vs landscape

If Iphone 5 (320x568) is in the portrait mode its width is 320px. 如果Iphone 5(320x568)处于纵向模式,则其宽度为320px。 When it is in the landscape mode is its width 320px and orientation is landscape, or its width is 568px and the orientation is landscape. 当处于横向模式时,其宽度为320px,方向为横向,或者其宽度为568px,方向为横向。 I am talking about the width that CSS sees. 我说的是CSS看到的宽度。

In other words, does this code work in landscape mode as well, so the site (wrapped by #container) occupies the whole screen in this case and not just the 320px? 换句话说,此代码是否也适用于横向模式,因此在这种情况下,该网站(由#container包装)占据了整个屏幕,而不仅仅是320px?

@media (max-width: 568px) and (min-width:320) {
#container {
    max-width: 790px;
    width: 100%;
      } 

you want this 你要这个

Portrait is taller, landscape is wider. 人像越高,风景越宽。

@media all and (orientation:portrait) {
  /* Styles for Portrait screen */
}
@media all and (orientation:landscape) {
  /* Styles for Landscape screen */
}

http://www.hongkiat.com/blog/css-orientation-styles/ http://www.hongkiat.com/blog/css-orientation-styles/

Short answer: For an iphone 5 with those dimensions, your code will always apply. 简短答案:对于具有这些尺寸的iPhone 5,您的代码将始终适用。

Explanation: Think of min-width as 说明:认为min-width

The minimum width on which this CSS will apply (anything lower will not count) 此CSS适用的最小宽度(任何较低的宽度均不计算在内)

likewise consider max-width as 同样考虑max-width

The maximum width on which this CSS will apply (anything higher will not count) 此CSS适用的最大宽度(更高的值将不会计入)

Note that you are applying a width:100% in a range between 320px and 568px . 请注意,您要应用的width:100%介于320px568px之间。 This means that the line max-width: 790px; 这意味着该行的max-width: 790px; will never be executed since the highest value width:100% can return is 568px 由于最大值width:100%可以返回的值为568px将永远不会执行

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

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