1、标准盒模型
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>标准盒</title>
<style>
body{background:#fff; font-size:14px; font-family:"microsoft yahei",Verdana, Arial; line-height:150%; margin:5px 0 0 0; padding:0; color:#000;}
div{margin:0 auto; padding:0;}
h1,h2,h3,h4,h5,h6,ul,li,dl,dt,dd,form,img,p{
margin:0; padding:0; border:none; list-style-type:none;
}
a{color:#000;text-decoration: none;}
.clearfix:after{content:"."; display:block; height:0; clear:both;visibility:hidden;}
*html .clearfix{height:1%;}
*+html .clearfix{height:1%;}
@font-face {
font-family: "iconfont"; /* Project id */
src: url('iconfont.ttf?t=1637035149022') format('truetype');
}
.iconfont {
font-family: "iconfont" !important;
font-size: 16px;
font-style: normal;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.icon-gengduo:before {
content: "\ec1c";
}
.icon-xiajiantou:before {
content: "\e629";
}
.fl{
float: left;
}
.headerbox{
width: 100%;
height: 60px;
background: #fff;
box-shadow: 0 4px 8px 0 rgba(7,17,27,.1);
}
.container{
width: 1200px;
margin: 0 auto;
}
.logo{
width: 140px;
height: 60px;
}
.logo img{
max-width: 140px;
max-height: 60px;
}
.navbox{
margin-left: 20px;
}
.navbox li{
float: left;
position: relative;
line-height: 60px;
}
.navbox>ul>li>a{
display: block;
padding:0 20px;
font-size: 15px;
}
.navbox>ul>li a:hover{
color:#f00;
}
.navbox>ul>li>a>span{
padding-left: 5px;
}
.navbox>ul>li.more .iconfont{
font-size: 18px;
font-weight: bold;
}
.navbox .childbox{
display: none;
position:absolute;
left:0;
top:60px;
width: 120px;
background: #fff;
box-shadow: 0 2px 4px rgba(0,0,0,.12);
padding: 5px 0;
}
.navbox .childbox .child_item{
height: 35px;
line-height: 35px;
padding: 0 20px;
}
.navbox>ul>li:hover .childbox{
display: block;
}
</style>
</head>
<body>
<div class="headerbox">
<div class="container clearfix">
<div class="logo fl">
<a href="./"><img src="images/PHPlogo.png" alt="名称" /></a>
</div>
<div class="navbox fl">
<ul>
<li><a href="#">首页</a></li>
<li>
<a href="#">视频教程<span class="iconfont icon-xiajiantou"></span></a>
<div class="childbox">
<div class="child_item">
<a href="#">视频课程</a>
</div>
<div class="child_item">
<a href="#">直播课程</a>
</div>
</div>
</li>
<li>
<a href="#">学习路径<span class="iconfont icon-xiajiantou"></span></a>
<div class="childbox">
<div class="child_item">
<a href="#">入门教程1</a>
</div>
<div class="child_item">
<a href="#">入门教程2</a>
</div>
</div>
</li>
<li><a href="#">大前端</a></li>
<li><a href="#">资源下载</a></li>
<li><a href="#">技术文章</a></li>
<li><a href="#">社区</a></li>
<li class="more">
<a href="#"><span class="iconfont icon-gengduo"></span></a>
<div class="childbox">
<div class="child_item">
<a href="#">编程词典</a>
</div>
<div class="child_item">
<a href="#">APP下载</a>
</div>
</div>
</li>
</ul>
</div>
</div>
</div>
</body>
</html>
2、弹性盒模型
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>弹性盒</title>
<style>
body{background:#fff; font-size:14px; font-family:"microsoft yahei",Verdana, Arial; line-height:150%; margin:5px 0 0 0; padding:0; color:#000;}
div{margin:0 auto; padding:0;}
h1,h2,h3,h4,h5,h6,ul,li,dl,dt,dd,form,img,p{
margin:0; padding:0; border:none; list-style-type:none;
}
a{color:#000;text-decoration: none;}
.clearfix:after{content:"."; display:block; height:0; clear:both;visibility:hidden;}
*html .clearfix{height:1%;}
*+html .clearfix{height:1%;}
@font-face {
font-family: "iconfont"; /* Project id */
src: url('iconfont.ttf?t=1637035149022') format('truetype');
}
.iconfont {
font-family: "iconfont" !important;
font-size: 16px;
font-style: normal;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.icon-gengduo:before {
content: "\ec1c";
}
.icon-xiajiantou:before {
content: "\e629";
}
.headerbox{
display:flex;
height: 60px;
background: #fff;
box-shadow: 0 4px 8px 0 rgba(7,17,27,.1);
}
.logo{
flex-grow: 1;
height: 60px;
text-align: center;
}
.logo img{
max-width: 100%;
max-height: 60px;
}
.navbox{
flex-grow: 3;
}
.navbox ul{
display:flex;
}
.navbox li{
flex-grow: 1;
position: relative;
line-height: 60px;
}
.navbox>ul>li>a{
display: block;
padding:0 20px;
font-size: 15px;
}
.navbox>ul>li a:hover{
color:#f00;
}
.navbox>ul>li>a>span{
padding-left: 5px;
}
.navbox>ul>li.more .iconfont{
font-size: 18px;
font-weight: bold;
}
.navbox .childbox{
display: none;
position:absolute;
left:0;
top:60px;
width: 120px;
background: #fff;
box-shadow: 0 2px 4px rgba(0,0,0,.12);
padding: 5px 0;
}
.navbox .childbox .child_item{
height: 35px;
line-height: 35px;
padding: 0 20px;
}
.navbox>ul>li:hover .childbox{
display: block;
}
</style>
</head>
<body>
<div class="headerbox">
<div class="logo">
<a href="./"><img src="images/PHPlogo.png" alt="名称" /></a>
</div>
<div class="navbox">
<ul>
<li><a href="#">首页</a></li>
<li>
<a href="#">视频教程<span class="iconfont icon-xiajiantou"></span></a>
<div class="childbox">
<div class="child_item">
<a href="#">视频课程</a>
</div>
<div class="child_item">
<a href="#">直播课程</a>
</div>
</div>
</li>
<li>
<a href="#">学习路径<span class="iconfont icon-xiajiantou"></span></a>
<div class="childbox">
<div class="child_item">
<a href="#">入门教程1</a>
</div>
<div class="child_item">
<a href="#">入门教程2</a>
</div>
</div>
</li>
<li><a href="#">大前端</a></li>
<li><a href="#">资源下载</a></li>
<li><a href="#">技术文章</a></li>
<li><a href="#">社区</a></li>
<li class="more">
<a href="#"><span class="iconfont icon-gengduo"></span></a>
<div class="childbox">
<div class="child_item">
<a href="#">编程词典</a>
</div>
<div class="child_item">
<a href="#">APP下载</a>
</div>
</div>
</li>
</ul>
</div>
</div>
</body>
</html>