开发者

CSS Media Queries Unexpected behavior

开发者 https://www.devze.com 2023-03-18 05:49 出处:网络
I’m getting some odd results with my tests. I’m using a dual monitor setup and while testing the media queries on the “main” monitor,everything works just fine width scaling the browser window etc

I’m getting some odd results with my tests. I’m using a dual monitor setup and while testing the media queries on the “main” monitor,everything works just fine width scaling the browser window etc. But when I move the browser to the secondary monitor, I’m getting orientation landscape back and the design switches to the “tablet mode”.

Windows 7 64

Chrome:

Gets orientation on secondary monitor

FF5:

Gets orientation on secondary monitor

Opera 11.5:

Gets orientation on All monitors

IE9:

Works as expected

Sample Code:

/* CSS Document */
* { margin:0px; padding:0px; }

#pc { background:red; }

@media (max-width:1280px) {
    #pc { background:white; }
    #pc2 { background:red; }
}

@media (max-device-width:1280px) and (orientation: landscape) {
    #pc { background:white; }
    #tablet_andr_ls { background:red; }
}

@media (max-device-width:1024px) and (orientation: landscape) {
    #pc { background:white; }
    #tablet_ipad_ls { background:red; }
}

@media (max-device-width:800px) and (orientation: portrait) {
    #pc { background:white; }
    #tablet_andr_pt开发者_如何学JAVA { background:red; }
}

@media (max-device-width:768px) and (orientation: portrait) {
    #pc { background:white; }
    #tablet_ipad_pt { background:red; }
}

HTML Sample:

<div id="container">

    <div id="pc"><p>PC Huge</p></div>

    <div id="pc2"><p>PC Small</p></div>

    <div id="tablet_andr_ls"><p>Android Tablet: Orientation Landscape</p></div>

    <div id="tablet_ipad_ls"><p>iPad Tablet: Orientation Landscape</p></div>

    <div id="tablet_andr_pt"><p>Android Tablet: Orientation Portrait</p></div>

    <div id="tablet_ipad_pt"><p>iPad Tablet: Orientation Portrait</p></div>

    <div id="smartphone"><p>Smart phone</p></div>

</div>


Try using max-width and min-width instead of device-max-width, the min/max-width follows window size, the device-min/max-width will follow device size.

0

精彩评论

暂无评论...
验证码 换一张
取 消