Home > Web Front-end > HTML Tutorial > Css sets the image to be vertically centered_html/css_WEB-ITnose

Css sets the image to be vertically centered_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:54:18
Original
1008 people have browsed it

Note: Style settings are mainly for the parent element of the image, not the image element itself.

Css code [style of image parent point]:

<style>.box {    /*非IE的主流浏览器识别的垂直居中的方法*/    display: table-cell;    vertical-align:middle;    /*设置水平居中*/    text-align:center;    /* 针对IE的Hack */    *display: block;    *font-size: 175px;/*约为高度的0.873,200*0.873 约为175*/    *font-family:Arial;/*防止非utf-8引起的hack失效问题,如gbk编码*/   /* 实验数据 width:400px;    height:500px;    border: 1px solid black;*/}   </style>
Copy after login

Html code:

<div class="box">       <img src="图片路径" /></div>
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template