布局要根据:
开发习惯
难易程度
可维护性
来自己设置
小页面布局的html和css如下:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>CSS网页布局</title>
<link rel="stylesheet" href="css/index.css">
</head>
<body>
<!-- 头部 -->
<div class="header">
<div class="logo"><img src="image/logo.png"></div>
<div class="menu">
<ul>
<li>手记</li>
<li>视频</li>
<li>图片</li>
<li>首页</li>
</ul>
</div>
</div>
<!-- 主体 -->
<div class="main">
<!-- 大图 -->
<div class="pic">
<img src="image/1.jpeg">
</div>
<!-- 遮罩层 -->
<div class="topLayer">
</div>
<!-- 最上层的内容 -->
<div class="btn">
<p>My Tragedy Life</p>
<button>look more ></button>
</div>
<!-- 内容展示区 -->
<div class="content">
<!-- 上部分 -->
<div class="top">
<div>
<div class="icon weibo">
<img src="image/weibo.png" alt="">
<div class="des">微博</div>
</div>
<div class="icon weixin">
<img src="image/weixin.png" alt="">
<div class="des">微信</div>
</div>
<div class="icon qq">
<img src="image/qq.png" alt="">
<div class="des">QQ</div>
</div>
</div>
<div class="recept">
"I want to give good things to record down,<br>after the recall will be very beautiful."
</div>
<div class="picAndDes">
<div class="icon2 ">
<img src="image/03-01.jpg" alt="">
<div class="des1">Cool Image</div>
<div Class="des2">Record The Picture</div>
</div>
<div class="icon2">
<img src="image/03-02.jpg" alt="">
<div class="des1">Great Picture</div>
<div class="des2">Record The Picture</div>
</div>
<div class="icon2">
<img src="image/03-03.jpg" alt="">
<div class="des1">Cool Image</div>
<div class="des2">Record The Picture</div>
</div>
</div>
</div>
<div style="clear:both;"></div><!-- 不加这句话的话,下面的背景会上移 -->
<!-- 下部分 -->
<div class="bottom"><!--包裹层 -->
<div class="bottom-content"><!--内容层 -->
<div class="title">FROM THE PHOTO ALBUM</div>
<div class="picContent">
<dl>
<dt><img src="image/04-01.jpg"></dt>
<dd>
Life is like a book, just read more and more refined, more write more carefully. When read, mind open, all things have been indifferent to heart. Life is the precipitation.
</dd>
</dl>
<dl>
<dt><img src="image/04-02.jpg"></dt>
<dd>
Life is like a cup of tea, let people lead a person to endless aftertastes. You again good taste, it will always have a different taste, different people will have different taste more.
</dd>
</dl>
</div>
<div style="clear: both;"></div>
</div>
<div style="clear: both;"></div>
</div>
</div>
</div>
<!-- 底部 -->
<div class="footer">
© 2020 天ICP备5201314号
</div>
</body>
</html>
*{
padding: 0;
margin:0;
}
.header{
width: 100%;
height: 100px;
}
.header .logo img{
width:300px;
height: 85px;
margin-top: 8px;
margin-left: 150px;
float: left;
}
.header .menu{
height: 100px;
float: right;
}
.header .menu ul{
margin-right: 50px;
}
.header .menu li{
float: right;
list-style-type: none;
width: 80px;
font-family: "微软雅黑";
color: #7D7D7D;
font-size: 15px;
line-height: 100px;
font-weight: bold;
text-align: center;
}
.main .pic img{
width: 100%;
height: 600px;
position: relative;
}
.topLayer{
background-color: #000000;
opacity: 0.5;
z-index: 1;
position: absolute;
top: 100px;
width: 100%;
height: 600px;
}
.main .btn{
z-index: 2;
width: 500px;
height: 300px;
position: absolute;
top: 400px;
margin-top:-150px;
right: 50%;
margin-right: -250px;
text-align: center;
}
.main .btn p{
padding-top: 100px;
color: #ffffff;
font-size: 45px;
font-family: "微软雅黑";
font-weight: bold;
}
.main .btn button{
margin-top: 50px;
background-color: #F5704F;
width: 200px;
height: 60px;
color: #ffffff;
font-family: "微软雅黑";
font-size: 14px;
text-align: center;
border-radius: 8px;
}
.main .content{
color: #7c7d7f;
font-size: 20px;
font-weight: bold;
}
.main .content .top{
width: 1000px;
padding-top: 50px;
margin:0 auto;
}
.main .content .top .icon{
float: left;
width: 33.3%;
text-align: center;
}
.main .content .top .icon img{
width:100px;
height:100px;
}
.main .content .top .icon .des{
padding-top: 20px;
}
.main .content .top .recept{
padding-top: 50px;
clear: both;
font-size: 22px;
text-align: center;
color: #E19796;
font-weight: bold;
font-style:italic ;
}
.main .content .top .picAndDes{
padding-top: 50px;
}
.main .content .top .picAndDes .icon2{
float: left;
text-align: center;
padding: 10px;
}
.main .content .top .picAndDes .icon2 .des1{
padding-top: 10px;
font-size: 20px;
font-weight: bold;
color: #7c7d7f;
}
.main .content .top .picAndDes .icon2 .des2{
color: #BDBDBC;
padding-top: 10px;
}
.main .content .top .picAndDes .icon2 img{
width: 310px;
height: 260px;
}
.main .content .bottom {
width: 100%;
padding-bottom: 30px;
background-color: #F9F9F9;
}
.main .content .bottom .bottom-content {
width: 1000px;
margin: 0 auto;
margin-bottom: 50px;
}
.main .content .bottom .bottom-content .title{
text-align: center;
padding-top: 50px;
font-family: "微软雅黑";
padding-bottom: 40px;
font-size: 20px;
}
.main .content .bottom .bottom-content .picContent dl{
width: 470px;
float: left;
margin:10px 12px 10px 12px;
}
.main .content .bottom .bottom-content .picContent dl dd{
padding-top: 20px;
}
.main .content .bottom .bottom-content .picContent dl dt img{
width:470px;
height:480px;
}
.footer{
width: 100%;
height: 100px;
background-color: #292C35;
color: #ffffff;
text-align: center;
line-height: 100px;
font-family: "微软雅黑";
font-size: 15px;
}
网页布局最主要的是靠自己去不断练习,发现错误,纠正错误。