DroidOS
DroidOS

Reputation: 8890

What is wrong with this media query

I would be much obliged to anyone who might be able to tell me why this media query only works partially (the font size changes but not the color).

<div>
<span id='one'>This is one 
<span id='two'>and this is two</span>
 and now back in one</span>
</div>

@media all and (min-width:500px)
{
 #two{font-size:2em;color:#0000ff;text-decoration:underline;}
}

#two{color:red;}

Here is a fiddle showing the problem in action. Just drag the resize bar to adjust the size of the output window. The font size changes as expected but the color stays put.

Upvotes: 0

Views: 32

Answers (2)

Manish Gautam
Manish Gautam

Reputation: 516

try using this

#two{color:red;}

@media all and (min-width:500px){
    #two{
        font-size:2em;
        color:green;
        text-decoration:underline
    }
}

Upvotes: 0

Vucko
Vucko

Reputation: 20834

Because #two{color:red;} overrides the style in the media query because you put it after the media query. Put it before - JSFiddle

Upvotes: 3

Related Questions