4-3作业中关于垂直居中的问题
来源:4-3 编程练习
慕码人1565653
2018-03-05 20:02:16
<!DOCTYPE html>
<html>
<head>
<title>css定位</title>
<meta charset="utf-8">
<style type="text/css">
.background{
width: 100%;
height: 4000px;
background:url(http://climg.mukewang.com/59c9f7ce0001839219034033.png) center top no-repeat;
}
.left{
left: 0;
top: 50%;
margin-top: -150px;
position: fixed;
}
.right{
right:0;
top:50%;
margin-top:-150px;
position: fixed;
}
</style>
</head>
<body>
<div class="background">
<div class="left"><img src="http://climg.mukewang.com/5a3383c70001f1b702240364.png"></div>
<div class="right"><img src="http://climg.mukewang.com/5a3383d00001a3dd02240364.png"></div>
</div>
</body>
</html>
请问一下老师,我们不知道这张图片具体的高度,那么在让它居中时,怎么来设置它的margin-top值呢?1回答
且听灬风吟
2018-03-06
打开图片地址,按F12查看源码可以看图片的大小规格啊,或者图片保存下来右键查看属性,或者打开PS查看等等一堆方法
相似问题