媒体查询:当窗口宽度小于600像素时,如何使文本更改颜色 [英] Media query: how to make text change color when window width gets below 600px
本文介绍了媒体查询:当窗口宽度小于600像素时,如何使文本更改颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当窗口尺寸小于600像素时,我想使文本更改颜色:
I want to make my text change color when the window size gets below 600px:
jsfiddle: http://jsfiddle.net/LgsXT/1/
jsfiddle: http://jsfiddle.net/LgsXT/1/
文本:
<div class = "derp">derp derp derp</div>
css:
.derp {
color:red;
}
@media (max-width:600) {
.derp {
color:blue;
}
}
但是它什么也没做.怎么了?
But it's not doing anything. What's wrong?
推荐答案
@media规则需要px或其他单位. 另外,请注意HTML中的空格,建议您提高而不是缩小屏幕尺寸
You need a px or other unit for the @media rule. Also, watch those spaces in your HTML, and I would suggest you work up instead of down in screen-size
<div class="my-box">Derp</div>
.my-box {
color: red;
}
@media (min-width: 600px) {
.my-box {
color:blue;
}
} /* end break point */
这是一个更强大的小提琴
这篇关于媒体查询:当窗口宽度小于600像素时,如何使文本更改颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文