Chr*_*her 1 css media screen width display
我在 DIV 中有一个段落,当宽度 > 500 时我想完全隐藏它,并在宽度 < 500 时显示。我不确定这里有什么问题。
<head>
<style type="text/css">
#mobileshow { display:none; }
@media screen and (max-width: 500px) {
#mobileshow { display:block; }
}
</style>
</head>
<div id="mobileshow"><p>Click the images below to download.</p></div>
Run Code Online (Sandbox Code Playgroud)
显然我的格式是错误的。在错误的地方有太多的空格或换行符。不确定哪个。这是更新后的代码:
<style type="text/css">
#mobileshow {
display:none;
}
@media screen and (max-width: 500px) {
#mobileshow {
display:block; }
}
</style>
<div id="mobileshow"><p>Click the images below to download.</p></div>
Run Code Online (Sandbox Code Playgroud)