• September 30, 2022
    <style type="text/css">
        /* default styles here for older browsers. 
           I tend to go for a 600px - 960px width max but using percentages
        */
        @media only screen and (min-width: 960px) {
            /* styles for browsers larger than 960px; */
        }
        @media only screen and (min-width: 1440px) {
            /* styles for browsers larger than 1440px; */
        }
        @media only screen and (min-width: 2000px) {
            /* for sumo sized (mac) screens */
        }
        @media only screen and (max-device-width: 480px) {
           /* styles for mobile browsers smaller than 480px; (iPhone) */
        }
        @media only screen and (device-width: 768px) {
           /* default iPad screens */
        }
        /* different techniques for iPad screening */
        @media only screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:portrait) {
          /* For portrait layouts only */
        }
    
        @media only screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:landscape) {
          /* For landscape layouts only */
        }
    </style>

    The underlying issue is using max-device-width vs plain old max-width.
    Using the “device” keyword targets physical dimension of the screen, not the width of the browser window.

    For example:
    
    @media only screen and (max-device-width: 480px) {
        /* STYLES HERE for DEVICES with physical max-screen width of 480px */
    }
    

    Versus

    @media only screen and (max-width: 480px) {
        /* STYLES HERE for BROWSER WINDOWS with a max-width of 480px. 
           This will work on desktops when the window is narrowed.  */
    }

    If website on small devices behavior like desktop screen then you have to put this meta tag into header before

    <meta name="viewport" content="width=device-width, initial-scale=1">
    

    For media queries you can set this as

    this will cover your all mobile/cellphone widths

     @media only screen and (min-width: 200px) and (max-width: 767px)  {
        //Put your CSS here for 200px to 767px width devices (cover all width between 200px to 767px //
       
        }
    

    For iPad and iPad pro you have to use

      @media only screen and (min-width: 768px) and (max-width: 1024px)  {
            //Put your CSS here for 768px to 1024px width devices(covers all width between 768px to 1024px //   
      }

    If you want to add css for Landscape mode you can add this

    and (orientation : landscape)

      @media only screen and (min-width: 200px) and (max-width: 767px) and (orientation : portrait) {
            //Put your CSS here for 200px to 767px width devices (cover all mobile portrait width //        
      }

    The correct value for the content attribute should include initial-scale instead:

    <meta name="viewport" content="width=device-width, initial-scale=1">
                                                       ^^^^^^^^^^^^^^^

    If you want to include both min and max width for responsiveness in the browser, then you can use the following:

     @media (min-width: 768px) and (max-width: 992px){...}
     @media (min-width: 480px) and (max-width: 767px) {...}


เวอไนน์ไอคอร์ส

ประหยัดเวลากว่า 100 เท่า!






เวอไนน์เว็บไซต์⚡️
สร้างเว็บไซต์ ดูแลเว็บไซต์

Categories


Uncategorized