Reputation: 489
I have this css
@media screen and (max-width :300px) {
.ui-tabs .ui-tabs-nav .ui-tabs-anchor {
float: left;
text-decoration: none;
}
}
which meas that I want to change the css when the size becomes less that 300 px
I have added this meta
<meta name="viewport" content="width=device-width, initial-scale=1.0">
This is my default css
.ui-tabs .ui-tabs-nav .ui-tabs-anchor {
float: left;
padding: .5em 1em;
text-decoration: none;
}
and in the firebug, I always see that one, not the one in media
Upvotes: 0
Views: 55
Reputation: 2260
Your media query css has the same properties as your default css and with the same values, that won't do anything. You need to set the value that must change and only that, lets say, you want to remove the padding, you then specify that in the media query, be aware that for this to work, it must be below your default css (Cascade style) or the default will take precedence. So always remember that the media query rule will be applied on top of your default, not instead.
Here is an example based on your code, and as you can see it works as it should:
Html
<div class="ui-tabs">
<nav class="ui-tabs-nav">
<a href="#" class="ui-tabs-anchor">Link 1</a>
</nav>
</div>
Css
.ui-tabs .ui-tabs-nav .ui-tabs-anchor {
float: left;
padding: .5em 1em;
text-decoration: none;
background: red;
display:block;
}
@media screen and (max-width :300px) {
.ui-tabs .ui-tabs-nav .ui-tabs-anchor {
padding: 0;
}
}
Note Sometimes you must add the '!important' flag to the property value if it was set in the default by targeting its id.
Upvotes: 1