Search code examples
csshtmlmedia-queries

responsive @media query to remove style declarations


I'm unfamiliar with @media queries, and what I'm trying to accomplish is a responsive removal/alteration of certain CSS when the browser viewing is shrunk below a certain resolution, or a mobile device viewing the page is also below that same specified resolution.

I need .side to remove float: left; position: fixed; width: 150px; when below 500px width resolution, and .main to remove border-left: 1px solid #000; margin: 0 0 0 170px;

.side {
  display: block;
  float: left;
  overflow: hidden;
  position: fixed;
  width: 150px;
}

.main {
  border-left: 1px solid #000;
  margin: 0 0 0 170px;
}

Any help or explanation is appreciated.


Solution

  • In this way you can do this

    @media only screen and (max-width: 500px) {
    
        .side {
          float: none;
          position: static;
          width: auto;
        }
    
        .main {
          border-left:0;
          margin: 0;
        }
    }