答案 0 :(得分:1)
您应该使用引导程序库或其他看起来相同的程序并在li标记中使用这些图标。它会给你相同的外观和感觉,如果你做自己,如果你是新的将是太难了。我想使用任何第三方下拉菜单并根据需要更改css。
答案 1 :(得分:1)
您可以使用互联网上提供的各种下拉组件
你也可以试试这个。
对于图标,您可以使用 Font awesome。
HTML code:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<style>
.dropbtn {
background-color: #4CAF50;
color: white;
padding: 16px;
font-size: 16px;
border: none;
cursor: pointer;
}
.dropbtn:hover, .dropbtn:focus {
background-color: #3e8e41;
}
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
overflow: auto;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.dropdown a:hover {background-color: #f1f1f1}
.show {display:block;}
</style>
</head>
<body>
<h2>Clickable Dropdown</h2>
<p>Click on the button to open the dropdown menu.</p>
<div class="dropdown">
<button onclick="myFunction()" class="dropbtn">Seminars <i class="fa fa-sort-desc" aria-hidden="true"></i></button>
<div id="myDropdown" class="dropdown-content">
<a href="#home"><i class="fa fa-heart-o" aria-hidden="true"></i> Home</a>
<a href="#about"><i class="fa fa-heart-o" aria-hidden="true"></i> About</a>
<a href="#contact"><i class="fa fa-heart-o" aria-hidden="true"></i> Contact</a>
</div>
</div>
<script>
/* When the user clicks on the button,
toggle between hiding and showing the dropdown content */
function myFunction() {
document.getElementById("myDropdown").classList.toggle("show");
}
// Close the dropdown if the user clicks outside of it
window.onclick = function(event) {
if (!event.target.matches('.dropbtn')) {
var dropdowns = document.getElementsByClassName("dropdown-content");
var i;
for (i = 0; i < dropdowns.length; i++) {
var openDropdown = dropdowns[i];
if (openDropdown.classList.contains('show')) {
openDropdown.classList.remove('show');
}
}
}
}
</script>
</body>
</html>
希望这会有所帮助。