I searched, but didn't find anything similar to my problem.
#navigation {
position: fixed;
top: 0;
width: 100%;
color: #ffffff;
height: 35px;
text-align: center;
padding-top: 15px;
-webkit-box-shadow: 0px 0px 8px 0px #000000;
-moz-box-shadow: 0px 0px 8px 0px #000000;
box-shadow: 0px 0px 8px 0px #000000;
background: url(../images/bg.jpg) repeat top left;
z-index: 9999;
}
#navigation a {
font-size: 15px;
padding-left: 15px;
padding-right: 15px;
color: #F2B704;
text-decoration: none;
}
#navigation a:hover {
color: #D78E02;
}
@media only screen and (max-device-width: 480px) {
#navigation a {
font-size: 10px;
}
}
<div id="navigation">
<a href="#galerija">GALERIJA</a>
<a href="#festival">FESTIVAL</a>
<a href="#kontakt">KONTAKT</a>
</div>
Media query doesn't result in changing my font-size
on smaller screen width, it still stays at 15px
. What did I do wrong?
In the media query, specify the font size of the text at any particular width and the font size will alter according to the device type. Another method of performing this task is to use the viewport width. This method simply requires you to assign a certain font size to the text in 'vw' unit.
CSS declared inline This may be the reason why your media queries aren't working. That is to say, you may have declared CSS within your HTML document. So if this is the case, simply go through the HTML document and remove the CSS declared inline. Alternatively, you can override the inline CSS with !
Use a comma to specify two (or more) different rules: @media screen and (max-width: 995px), screen and (max-height: 700px) { ... } Commas are used to combine multiple media queries into a single rule. Each query in a comma-separated list is treated separately from the others.
Media queries can be used to check many things, such as: width and height of the viewport. width and height of the device. orientation (is the tablet/phone in landscape or portrait mode?)
You use max-device-width: 480px
in your media query so you have to havemeta viewport
to browser detect the width of devices.
<meta name="viewport" content="width=device-width, initial-scale=1">
There is not wrong with your code. You can change max-device-width: 480px
to max-width: 480px
to see your code works. You only need to add meta viewport in your head
tag.
Jsffidle
Try this:
@media (max-width: 480px) {
#navigation a {
font-size: 10px !important;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With