html - 如何修复:我的背景在菜单下
问题描述
我正在制作一个网站,我想做一个不应该掩盖我的背景的子菜单。如何解决?
过去,我尝试过多种背景,但它不起作用。
HTML
<nav>
<label for="show-menu" class="show-menu">Menu</label>
<input type="checkbox" id="show-menu" role="button">
<ul id="menu">
<li ><a class="current" href="#">Home</a></li>
<li><a href="#">Sobre</a></li>
<li><a href="#">Contato</a></li>
</ul>
</nav>
<!-- Showcase -->
<section id="showcase">
<div class="monitor"><img src="images/monitor.png" alt="monitor"></div>
<!-- <div class="front"><img src="images/front-end.jpg" alt="front-end">
</div> -->
</section>
这里是css:https ://jsfiddle.net/enzoap/84hu0m3s/2/
我希望banner图像跟随“monitor”图像,即把banner和monitor图像一起推送,并且菜单是正确的,我只想修复子菜单,即覆盖banner。
解决方案
您的示例最简单的解决方案是更改此样式:
input[type=checkbox]:checked ~ #menu {
display: block;
}
对此:
input[type=checkbox]:checked ~ #menu {
display: inline-block; // This is the setting on the menu before `display: none` is set, so we reset it to this when the menu is displayed.
width: 100%; // This could also be placed into the `ul` styles
}
老实说,我不是 100% 确定为什么会这样,但我在您的 JSFiddle 示例中对其进行了测试,并且我相信您希望它执行此操作。
推荐阅读
- python - PyQt5 QGraphicsView 对象没有属性'resetMatrix'?
- c# - PreviewMouseDown 绑定
- python - cx_Oracle.DatabaseError: DPI-1047
- lua - rtcmem 似乎无法在节点重新启动后幸存下来,因为它应该
- java - 关于快速点击图像的游戏,哪个选项更好:SetOnClicklistener 或设计视图中的 OnClick?
- sql-server - TFS 2018 数据库
- r - 如何对 data.frame 中的多列进行夏皮罗测试?并避免 2 个错误:需要 TRUE/FALSE 的值相同且缺失值
- php - long2ip 不适用于数据库中的字符串
- sql - 在 SQL 中使用 OR 排除结果的查询
- java - 从 Java 应用程序将数据块保存到数据库中