如何在移动时隐藏div
How to hide div when mobile
我发布了一个公告div,我希望它在我使用网页的移动版本时消失,因为在为移动版本调整大小时它占据了很多space。
如何在网页变大后隐藏一个div?
例如:手机上网
我的密码是
body {margin:0;}
.icon-bar {
width: 100%;
background-color: #0088B8;
overflow: auto;
}
.icon-bar a {
float: left;
width: 20%;
text-align: center;
padding: 12px 0;
transition: all 0.3s ease;
color: white;
font-size: 36px;
}
.icon-bar a:hover {
background-color: #0073C4;
}
.active {
background-color: #9b0a0a !important;
}
<div class="icon-bar">
<a href="./index.php"><i class="fa fa-home"></i></a>
<a href="./search.php"><i class="fa fa-search"></i></a>
<a href="./news.php"><i class="fa fa-envelope"></i></a>
<a href="./search.php?search_id=unanswered"><i class="fa fa-globe"></i></a>
<a href="#"><i class="fa fa-trash"></i></a>
</div>
也许他是 html 和 css 的新手...
尝试使用 css 规则来实现这一点,就像罗伯特所说的媒体查询。
在你的 html 标题中输入这一行:
<meta name="viewport" content="width=device-width, initial-scale=1.0">
并且在您的 css 文件中写在您的 div-rules 下方(假设您的 div 具有 id="test"):
@media only screen and (min-width: 800px) {
#test {
display: none;
}
}
现在 div 在屏幕宽度大于例如800px.
我发布了一个公告div,我希望它在我使用网页的移动版本时消失,因为在为移动版本调整大小时它占据了很多space。 如何在网页变大后隐藏一个div?
例如:手机上网
我的密码是
body {margin:0;}
.icon-bar {
width: 100%;
background-color: #0088B8;
overflow: auto;
}
.icon-bar a {
float: left;
width: 20%;
text-align: center;
padding: 12px 0;
transition: all 0.3s ease;
color: white;
font-size: 36px;
}
.icon-bar a:hover {
background-color: #0073C4;
}
.active {
background-color: #9b0a0a !important;
}
<div class="icon-bar">
<a href="./index.php"><i class="fa fa-home"></i></a>
<a href="./search.php"><i class="fa fa-search"></i></a>
<a href="./news.php"><i class="fa fa-envelope"></i></a>
<a href="./search.php?search_id=unanswered"><i class="fa fa-globe"></i></a>
<a href="#"><i class="fa fa-trash"></i></a>
</div>
也许他是 html 和 css 的新手... 尝试使用 css 规则来实现这一点,就像罗伯特所说的媒体查询。 在你的 html 标题中输入这一行:
<meta name="viewport" content="width=device-width, initial-scale=1.0">
并且在您的 css 文件中写在您的 div-rules 下方(假设您的 div 具有 id="test"):
@media only screen and (min-width: 800px) {
#test {
display: none;
}
}
现在 div 在屏幕宽度大于例如800px.