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

时间:2016-01-24 17:21:14

标签: html css html5 css3



#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>
&#13;
&#13;
&#13;

对于这个项目,我使用FontAwesome图标。我需要&#34; fa-list-ul&#34;下拉菜单与他的子菜单。试图使用大量的CSS框架,但我无法获得足够的结果。我希望SOMEBODY可以帮助我解决我的问题。 谢谢你

1 个答案:

答案 0 :(得分:1)

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

&#13;
&#13;
.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;
}
&#13;
<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>
&#13;
&#13;
&#13;