我不知道这段代码出了什么问题。背景颜色完全不变,只是在整个过程中保持白色。
<style type="text/css">
h1 {
position: absolute;
text-align: center;
width: 100%;
font-size: 6em;
font-family: Roboto;
transition: all 0.5s;
}
@media screen and (min-width: 0px) and (max-width: 400px) {
background-color: red;
}
@media screen and (min-width: 401px) and (max-width: 599px) {
background-color: green;
}
@media screen and (min-width: 600px) {
background-color: blue;
}
</style>
尝试:
@media screen and (min-width: 0px) and (max-width: 400px) {
body { background-color: red; }
}
@media screen and (min-width: 401px) and (max-width: 599px) {
body { background-color: green; }
}
@media screen and (min-width: 600px) {
body { background-color: blue; }
}
background-color
现在,该属性已分配给body
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句