Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 968
questy Avatar asked Sep 02 '13 09:09

questy


2 Answers

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;
    }
}
like image 138
Roy Sonasish Avatar answered Sep 22 '22 12:09

Roy Sonasish


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

.main {
  border-left: 1px solid #000;
  margin: 0 0 0 170px;
  width: auto;
}
@media only screen and (max-device-width : 500px) {
  .side {
    float: none;
    position: static;
    width: auto;
  }
  .main {
    border: 0;
    margin: 0;
  }
}
like image 20
LinkinTED Avatar answered Sep 22 '22 12:09

LinkinTED