How to set portrait and landscape media queries in css?

后端 未结 2 1422
萌比男神i
萌比男神i 2020-12-08 04:18

Here is my media query:

@media screen and (min-device-width: 768px) and (max-device-width: 1824px) and (orientation : portrait){
  .hidden-desktop {
    disp         


        
相关标签:
2条回答
  • 2020-12-08 04:49

    iPad Media Queries (All generations - including iPad mini)

    Thanks to Apple's work in creating a consistent experience for users, and easy time for developers, all 5 different iPads (iPads 1-5 and iPad mini) can be targeted with just one CSS media query. The next few lines of code should work perfect for a responsive design.

    iPad in portrait & landscape

    @media only screen 
    and (min-device-width : 768px) 
    and (max-device-width : 1024px)  { /* STYLES GO HERE */}
    

    iPad in landscape

    @media only screen 
    and (min-device-width : 768px) 
    and (max-device-width : 1024px) 
    and (orientation : landscape) { /* STYLES GO HERE */}
    

    iPad in portrait

    @media only screen 
    and (min-device-width : 768px) 
    and (max-device-width : 1024px) 
    and (orientation : portrait) { /* STYLES GO HERE */ }
    

    iPad 3 & 4 Media Queries

    If you're looking to target only 3rd and 4th generation Retina iPads (or tablets with similar resolution) to add @2x graphics, or other features for the tablet's Retina display, use the following media queries.

    Retina iPad in portrait & landscape

    @media only screen 
    and (min-device-width : 768px) 
    and (max-device-width : 1024px)
    and (-webkit-min-device-pixel-ratio: 2) { /* STYLES GO HERE */}
    

    Retina iPad in landscape

    @media only screen 
    and (min-device-width : 768px) 
    and (max-device-width : 1024px) 
    and (orientation : landscape)
    and (-webkit-min-device-pixel-ratio: 2) { /* STYLES GO HERE */}
    

    Retina iPad in portrait

    @media only screen 
    and (min-device-width : 768px) 
    and (max-device-width : 1024px) 
    and (orientation : portrait)
    and (-webkit-min-device-pixel-ratio: 2) { /* STYLES GO HERE */ }
    

    iPad 1 & 2 Media Queries

    If you're looking to supply different graphics or choose different typography for the lower resolution iPad display, the media queries below will work like a charm in your responsive design!

    iPad 1 & 2 in portrait & landscape

    @media only screen 
    and (min-device-width : 768px) 
    and (max-device-width : 1024px) 
    and (-webkit-min-device-pixel-ratio: 1){ /* STYLES GO HERE */}
    

    iPad 1 & 2 in landscape

    @media only screen 
    and (min-device-width : 768px) 
    and (max-device-width : 1024px) 
    and (orientation : landscape)
    and (-webkit-min-device-pixel-ratio: 1)  { /* STYLES GO HERE */}
    

    iPad 1 & 2 in portrait

    @media only screen 
    and (min-device-width : 768px) 
    and (max-device-width : 1024px) 
    and (orientation : portrait) 
    and (-webkit-min-device-pixel-ratio: 1) { /* STYLES GO HERE */ }
    

    Source: http://stephen.io/mediaqueries/

    0 讨论(0)
  • 2020-12-08 04:51

    It can also be as simple as this.

    @media (orientation: landscape) {
    
    }
    
    0 讨论(0)
提交回复
热议问题