方向更改和screen.width

时间:2016-09-01 10:28:59

标签: css css3 viewport

我注意到更改设备方向(Android手机)会导致Error:(14, 1) Groovyc: unable to resolve class jenkins.model.Jenkins更改。例如在我的华为Android手机上,当处于纵向位置screen.width == 360px而在横向640px时。考虑到(至少据我所知)screen.width保存screen.width属性值,为什么代码如下:

device-width

不起作用吗?

如果@media screen and (max-device-width:360px){ div { background-color: green; } } @media screen and (min-device-width:361px){ div { background-color: blue; } } device-width相关联,那么它的值会随着screen.width的实际设备方向而相应地改变吗?

1 个答案:

答案 0 :(得分:0)

  

设备宽度是指设备本身的宽度,换句话说,   设备的屏幕分辨率

你想要这样的东西吗?

/* Portrait */
@media screen 
  and (device-width: 360px) 
  and (device-height: 640px) 
  and (-webkit-device-pixel-ratio: 3) 
  and (orientation: portrait) {
  div {
    background-color: green;
  }
}

/* Landscape */
@media screen 
  and (device-width: 360px) 
  and (device-height: 640px) 
  and (-webkit-device-pixel-ratio: 3) 
  and (orientation: landscape) {
  div {
    background-color: blue;
  }
}