Search code examples
cssresponsive-designmedia-queries

CSS - responsive desidgn - media screen


I have a css code like this:

@charset "utf-8";
/* long code  just an example of top */
     .show_hide_top a.showLink {        /* small red link */
     left: 39% !important;
     padding-left: 8px;
     top: 15% ;
     }


@media only screen and (min-width: 1300px) and (max-width:1500px) { 
     /* long code for these devices ex: */
 .show_hide_top a.showLink {      
    left: 39% !important;
    padding-left: 8px;
    top: 18% ;
    }
}
@media only screen and (min-width: 769px) and (max-width:1299px) {     
      code for these devices
}

@media only screen and (min-width:481px) and (max-width: 768px) {
      code for these devices
}

However, my computer (1600) picks up the media code for the 1300-1500. Something (probably silly) is wrong.

Thank you so much for your opinion.


Solution

  • When I was using media query, firefox was not recognizing a generic id like #upper.

    Example:

    <div id="container">
       <div id='left"> content here </div>
       <div id="center">
          <div id="upper"> content here </div>
          ...
       </div>
       <div id="right">content here </div>
    </div>
    

    As soon as target #center #upper in the CSS, the media query worked ONLY for the target media and not as a generic rule.

    Only #upper? Nope... It was reading and applying the media query for all devices, overwriting the generic CSS.

    At first, toggling between min-devide-width and min-width seemed to work, but the problem persisted. So this is the permanent fix.

    Make sure to use both full path in the generic CSS and in the media query.