- This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
Viewing 6 posts - 1 through 6 (of 6 total)
- The forum ‘CSS’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Well, I’m mostly a PHP guy, and I’m wanting to improve my design skills. I know a fair amount of CSS (Sass, Scout etc) and I’m able to create a few good looking designs. However, I have a slight problem.
When I’m using “@media screen” to make my site device friendly, I’m having to constantly use “!important” to override my current CSS properties which I’ve declared at the top of my stylesheet otherwise my properties don’t take effect.
Any reason for this? Because I’ve never really experienced this kind of issue before.
One way to avoid specificity is to use classes and take a mobile first approach. Quick example:
Top of stylesheet:
nav.main-nav {
display: inline-block;
}
Bottom of stylesheet:
@media screen and (max-width: 600px) {
nav.main-nav {
/Doesn’t work unless I use !important/
display: block;
}
}
I don’t want to keep using !important because I heard it’s not really good to over use it. Plus, it’s also effecting the thing I’m trying to accomplish.
Alen – This for some reason didn’t work either :(
Yeah sure.
http://codepen.io/anon/pen/Xbdoep
Brilliant. That’s sorted it. Thanks a lot for your help. Much appreciated.