level 1
如何让图片,在DIV框中居中?高度设置一样了。
原理:图片套在DIV里,左右居中。可代码怎么写都写不出来。求大神。。。
.img123 {
width: 350px;
height: 495px;
background: #666666;
overflow: hidden;
}
.img123 img {
height: 495px;
}
2018年01月06日 06点01分
1
level 1
<style>
div {
width:200px;
height:300px;
background-color:red;
display:table-cell;/*设置div 的类型为table类型*/
vertical-align: middle;/*设置元素对父元素中部对齐*/
}
img {
width: 100%;
}
</style>
<body>
<div class="div1"><img src="img/3.png" alt="" class="img123" /></div>
</body
2018年01月06日 09点01分
6
你试试看 把这两代码加进去
2018年01月06日 09点01分