Home >Web Front-end >HTML Tutorial >The picture is horizontally, vertically and centered inside the div_html/css_WEB-ITnose
I want the image to be centered horizontally and vertically inside the blue box. What should I do?
I can only center it horizontally now
.pic_upload It’s div css
.pic_upload { width:180px; height:180px; float:left; margin:20px 0 0 20px; border:2px solid #5FA9E1; background-color:#F3F3F3; } .pic_upload img {display:block; margin:0 auto;}
table
At this time, the benefits of table are reflected
.pic_upload { width:180px; height:180px; float:left; margin:20px 0 0 20px; border:2px solid #5FA9E1; background-color:#F3F3F3; position:relative;/*使图片相对这个div绝对定位*/ }.pic_upload img { margin: auto; position: absolute; top: 0; left: 0; bottom: 0; right: 0;}
.pic_upload { width:180px; height:180px; float:left; margin:20px 0 0 20px; border:2px solid #5FA9E1; background-color:#F3F3F3; position:relative;/*使图片相对这个div绝对定位*/ }.pic_upload img { margin: auto; position: absolute; top: 0; left: 0; bottom: 0; right: 0;}
Yeah, hey.