gpt4 book ai didi

html - 使用css制作下拉菜单和子菜单导航

转载 作者:行者123 更新时间:2023-11-28 01:18:00 26 4
gpt4 key购买 nike

#header{
background: url("../images/naviBack.jpg");
width: 100%;
}
a{
display: block;

}
.ic{
color: #1B7EDB;
text-align: center;
display: inline-block;
font-size: 4vm;
}
<div id="header">

<ul class="list-group">
<li>
<a class="list-group-item" href="">
<i class="fa fa-home fa-4x fa-fw ic"></i>
</a>
</li>
<li>
<a class="list-group-item" href="">
<i class="fa fa-list-ul fa-4x fa-fw ic"></i>
</a>
</li>
<li>
<a class="list-group-item" href="">
<i class="fa fa-user fa-4x fa-fw ic"></i>
</a>
</li>
<li>
<a class="list-group-item" href="">
<i class="fa fa-question fa-4x fa-fw ic"></i>
</a>
</li>
</ul>



</div>

对于这个元素,我使用了 FontAwesome 图标。我需要带有子菜单的“fa-list-ul”下拉菜单。尝试使用很多 css 框架,但我无法获得足够的结果。我希望有人能帮我解决我的问题。谢谢你

最佳答案

请使用下面的代码,您也可以轻松制作其他菜单...

.dropbtn {
background-color: #4CAF50;
color: white;
padding: 16px;
font-size: 16px;
border: none;
cursor: pointer;
}

.dropdown {
position: relative;
display: inline-block;
}

.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
}

.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}

.dropdown-content a:hover {background-color: #f1f1f1}

.dropdown:hover .dropdown-content {
display: block;
}

.dropdown:hover .dropbtn {
background-color: #3e8e41;
}
<h2>Dropdown Menu</h2>
<p>Move the mouse over the button to open the dropdown menu.</p>

<div class="dropdown">
<button class="dropbtn">Dropdown</button>
<div class="dropdown-content">
<a href="#">Link 1</a>
<a href="#">Link 2</a>
<a href="#">Link 3</a>
</div>
</div>

<p><strong>Note:</strong> Please use href="#" for test links. In a real web site this would be URLs.</p>

关于html - 使用css制作下拉菜单和子菜单导航,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34978942/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com