Home > Web Front-end > HTML Tutorial > DIV CSS image centering method for mixed graphics and text_html/css_WEB-ITnose

DIV CSS image centering method for mixed graphics and text_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:44:10
Original
1933 people have browsed it

Many people use various SPAN, DIV, LI, etc. for IMG in order to center the DIV images mixed with text, so that they can use text-align for centering.

1 <div>图文混排2 <br>3 <span style="text-align:center"><img src="http://www.baidu.com/img/baidu_jgylogo3.gif"></span>4 </div>
Copy after login

For the centering of DIV, many people use the following method. However, this method is not suitable for IMG centering by default.

1 div{margin:0 auto}
Copy after login

This is because the IMG tag is an inline element (inline element). Inline elements do not support the Margin attribute. The Display attribute is used to force the IMG to be a block element. Display, the picture can be centered in the mixed arrangement of pictures and texts.

1 IMG {display:block;margin:0 auto;}
Copy after login



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