2-13编程,通知此方法实现了大概布局,怎么实现垂直居中?
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
*{
margin: 0;
padding:0;
}
ul li{
list-style: none;
}
.main{
width: 960px;
/*height: 100px;*/
margin: 0 auto;
background-color: #ADD8E6;
}
/* .header{
margin: 20px 0;
}*/
.left-pic,.right-pic{
width: 50%;
}
.left-pic{
float: left;
}
.left-pic img{
margin: 20px 0px 20px 80px;
}
.right-pic img{
margin: 20px 0px 20px 40px;
}
.right-pic{
float: right;
}
.footer{
clear: both;
background-color: pink;
/*padding: 20px 100px;*/
padding:40px 0;
}
.footer ul{
margin-left: 80px;
}
.footer ul li{
display: inline;
margin-right: 80px;
/*margin: 40px 100px 40px 100px;*/
}
</style>
</head>
<body>
<div class="main">
<div class="header">
<div class="left-pic">
<img src="http://img1.sycdn.imooc.com/climg//58c0f808000129a303600215.jpg">
</div>
<div class="right-pic">
<img src="http://img1.sycdn.imooc.com/climg//58c0f819000198a703600214.jpg">
</div>
</div>
<div class="footer">
<ul>
<li><img src="http://img1.sycdn.imooc.com/climg//58c0f81d0001fe4402000060.jpg"></li>
<li><img src="http://img1.sycdn.imooc.com/climg//58c0f8220001dfce02000060.jpg"></li>
<li style="float: right;"><img src="http://img1.sycdn.imooc.com/climg//58c0f8780001c74602000060.jpg"></li>
</ul>
</div>
</div>
</body>
</html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
*{
margin: 0;
padding:0;
}
ul li{
list-style: none;
}
.main{
width: 960px;
/*height: 100px;*/
margin: 0 auto;
background-color: #ADD8E6;
}
/* .header{
margin: 20px 0;
}*/
.left-pic,.right-pic{
width: 50%;
}
.left-pic{
float: left;
}
.left-pic img{
margin: 20px 0px 20px 80px;
}
.right-pic img{
margin: 20px 0px 20px 40px;
}
.right-pic{
float: right;
}
.footer{
clear: both;
background-color: pink;
/*padding: 20px 100px;*/
padding:40px 0;
}
.footer ul{
margin-left: 80px;
}
.footer ul li{
display: inline;
margin-right: 80px;
/*margin: 40px 100px 40px 100px;*/
}
</style>
</head>
<body>
<div class="main">
<div class="header">
<div class="left-pic">
<img src="http://img1.sycdn.imooc.com/climg//58c0f808000129a303600215.jpg">
</div>
<div class="right-pic">
<img src="http://img1.sycdn.imooc.com/climg//58c0f819000198a703600214.jpg">
</div>
</div>
<div class="footer">
<ul>
<li><img src="http://img1.sycdn.imooc.com/climg//58c0f81d0001fe4402000060.jpg"></li>
<li><img src="http://img1.sycdn.imooc.com/climg//58c0f8220001dfce02000060.jpg"></li>
<li style="float: right;"><img src="http://img1.sycdn.imooc.com/climg//58c0f8780001c74602000060.jpg"></li>
</ul>
</div>
</div>
</body>
</html>
23
收起
正在回答
3回答
你好,不加的话,默认值是 left: 0; top: 0; 所以会在左上角;
祝学习愉快~
前端小白入门系列课程
- 参与学习 人
- 提交作业 11218 份
- 解答问题 36713 个
从一个不会编程的小白到一个老司机是需要过程的,首先得入门,学习基础知识,然后才能进阶,最后再到精通,本专题是你走进前端世界的不二选择!
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星