运行结果
导航栏代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>navbar</title>
<link rel="stylesheet" href="http://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
<script src="http://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
<script src="http://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<style media="screen">
html{
font-size: 16px;
}
body{
font-family: arial;
}
.layout{
width:100%;
margin: auto;
}
.logo{
float: left;
}
.active_index{
box-sizing: border-box;
padding-left: 17rem;
}
.h-navbar{
height: 5rem;
margin: 0;
padding: 0;
list-style: none;
background-color: black;
height: 5rem;
}
.h-navbar:after {
display: block;
clear: both;
}
.h-navbar>li {
float: left;
position: relative;
z-index:9999;
}
.h-navbar li a {
box-sizing: border-box;
height: 5rem;
display: block;
padding: 1.5rem 1rem;
color: #FFFFFF;
font-size: 18px;
font-weight: 600;
text-decoration: none;
}
.h-navbar li a:hover {
color: deepskyblue;
background-color: #FFFFFF;
}
.h-navbar .child {
color: #FFFFFF;
background-color:#000;
display: none;
position: absolute;
top: 100%;
left: 0;
min-width: 160px;
margin: 0;
padding: 0;
}
.h-navbar>li:hover .child {
display: block;
}
</style>
</head>
<body>
<!--导航栏-->
<div class="layout">
<ul class="h-navbar" style="display: flex;justify-content: center;flex-direction: row">
<div class="logo">
<img src="#">
</div>
<li class="active_index">
<a href="#">首页</a>
</li>
<li>
<a href="#">专家团队</a>
</li>
<li>
<a href="#">案例中心</a>
<div class="child">
<a href="#">泌尿外科</a>
<a href="#">骨科</a>
<a href="#">康复科</a>
</div>
</li>
<li>
<a href="#">线下工作站</a>
</li>
<li>
<a href="#">重建打印</a>
</li>
<li>
<a href="#">行业资讯</a>
</li>
<li>
<a href="#">关于我们</a>
<div class="child">
<a href="#">平台简介</a>
<a href="#">合作机构</a>
<a href="#">联系我们</a>
</div>
</li>
</ul>
</div>
</body>
</html>