当前位置:Gxlcms > html代码 > div层中图片垂直居中的css样式_html/css_WEB-ITnose

div层中图片垂直居中的css样式_html/css_WEB-ITnose

时间:2021-07-01 10:21:17 帮助过:17人阅读

1、图片定义大小
.div{ border:1px solid #000;width:200px;
height:200px;position:relative;
}
.img {
position:absolute;
top:50%;
left:50%;
margin:-50px 0 0 -50px;
width:100px;
height:100px;
border:1px solid red;
}







2、图片不定义大小




利用定位来显示垂直局中的图片






固定高宽的容器中,图片垂直局中。



Logo




Logo




Google


人气教程排行