[英]Responsive menu icon issue
I have an issue. 我有一个问题。 I have a menu but I want to make it responsive with a button click ( font awesome) when i set display:none; 我有一个菜单,但是当我设置display:none时,我想通过单击按钮(字体很棒)做出响应。 and then display:block on the media query , my icon doesn't appear.. pls help. 然后在媒体查询上显示:block,我的图标没有出现。
html: 的HTML:
<div id="menuIcon">
<i class="fa fa-bars fa-3x" style="color:white"></i>
</div>
css: CSS:
@media screen and (min-width:320px) and (max-width:640px){
.menuRight{
display:none;
}
#menuIcon{
display:block;
float:right;
cursor:pointer;
}
}
#menuIcon{
display:none;
}
In your above code, the display:none; 在上面的代码中,显示:无; is below the display:block; 在display:block下面; so it is overriding it. 所以它覆盖了它。 Organize your code like this and it will work: 像这样组织代码,它将起作用:
#menuIcon{
display:none;
}
@media screen and (min-width:320px) and (max-width:640px){
.menuRight{
display:none;
}
#menuIcon{
display:block;
float:right;
cursor:pointer;
}
}
Also, see this on cascading: https://css-tricks.com/specifics-on-css-specificity/ 另外,请在级联上查看此内容: https : //css-tricks.com/specifics-on-css-specificity/
Maybe just try to set display: block;
也许只是尝试设置display: block;
as !important
. !important
!
If you add style to an element twice in your CSS file, CSS gives higher priority to the code added at the last. 如果您在CSS文件中两次向元素添加样式,则CSS会优先考虑最后添加的代码。
eg 例如
.box { color: #fff; }
.box { color: #000; }
The property of .box will be color: #000; .box的属性将为颜色:#000; since it was added at the last. 因为它是最后添加的。
Just change your code to the following: 只需将代码更改为以下内容:
#menuIcon{
display:none;
}
@media screen and (min-width:320px) and (max-width:640px){
.menuRight{
display:none;
}
#menuIcon{
display:block;
float:right;
cursor:pointer;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.