html - 如何修复导航栏和下拉内容,使其对齐而不重叠?
问题描述
如何修复导航栏,以使下拉菜单不会越过其父级并且与其一致?另外,当您将鼠标悬停在“关于”选项卡上时,如何填充它?正如你所看到的,它只填充了其中的一部分,直到导航栏的末尾。
有我的小提琴:https ://jsfiddle.net/Shade1337/29sd0g07/
.navigation {
overflow: hidden;
height: 60px;
border: 3px solid #E3E3E3;
background-color: #1f1d1d;
font-family: Arial, Helvetica, sans-serif;
width: 1078px;
}
.navigation a {
float: left;
font-size: 30px;
color: antiquewhite;
text-align: center;
padding: 18px 20px;
text-decoration: none;
width: 234px;
height: 25px;
}
.dropdown {
float: left;
overflow: hidden;
}
.dropdown .dropbtn {
border-style: none;
border-color: inherit;
font-size: 30px;
margin: 0;
outline: none;
color: antiquewhite;
padding: 18px 20px;
background-color: inherit;
font-family: inherit;
width: 214px;
height: 25px;
}
.navigation a:hover, .dropdown:hover .dropbtn {
background-color: #4e3f3f;
}
.dropdown-content {
overflow: hidden;
display: none;
position: absolute;
background-color: #1f1d1d;
min-width: 214px;
box-shadow: 0px 8px 16px 0px rgb(186,179,179);
z-index: 1;
}
.dropdown-content a {
float: none;
color: antiquewhite;
padding: 18px 20px;
text-decoration: none;
display: block;
text-align: center;
}
.dropdown-content a:hover {
background-color: #4e3f3f;
}
.dropdown:hover .dropdown-content {
display: block;
}
<div class="navigation">
<a href="#home">Home</a>
<div class="dropdown">
<button class="dropbtn">Types
<i class="fa fa-caret-down"></i>
</button>
<div class="dropdown-content">
<a href="#">Regular</a>
<a href="#">Cafe latte</a>
<a href="#">Espresso</a>
<a href="#">Cappuccino</a>
</div>
</div>
<a href="#shop">Shop</a>
<a href="#about">About</a>
</div>
解决方案
解决方案:-
您将在项目中添加引导 css 文件并根据您的要求使用引导类
有关更多信息,请访问链接:- https://getbootstrap.com/docs/3.3/getting-started/
推荐阅读
- c# - 添加新购买时,我想在另一个表中更新数量
- sql - 用于消除负值的 teradata 案例的雪花版本
- kdb - 保护执行,2 例
- python - 基于pandas数据框的多条件Oracle SQL查询
- javascript - 使用聚合函数 mongoose 检索特定电视节目剧集的所有信息,包括演员和导演
- c# - 为什么ban命令不起作用dsharpplus?
- flutter - 滑动以返回在 ios 中的颤振 webview 中不起作用
- html - HTML 输入的调度键盘事件未更新值
- sql-server - 如果在 SSMS 中不满足条件,where 子句不返回任何内容
- python-3.x - 为什么此事件调度程序中缺少默认处理程序?