rallybilen rallybilen - 1 year ago 99
CSS Question

@Media min-width & max-width

I have this



<meta name="viewport" content="width=device-width, user-scalable=no" />


@media screen and (min-width: 769px) {

@media screen and (min-device-width: 481px) and (max-device-width: 768px) {

@media only screen and (max-device-width: 480px) {

With this setup it works on the iPhone but it does not work in the browser.

It's really irritating so help is highly appreciated. Is it because I already have
in the meta and maybe have (
) instead?

Answer Source

I've found the best method is to write your default CSS for the older browsers, as older browsers including i.e. 5.5, 6, 7 and 8. Can't read @media. When I use @media I use it like this:

<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 */

But you can do whatever you like with your @media, This is just an example of what I've found best for me when building styles for all browsers.

iPad CSS specifications.

Also! If you're looking for printability you can use @media print{}

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download