Home  >  Article  >  Web Front-end  >  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
WBOYOriginal
2016-06-24 11:44:101863browse

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>

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}

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;}



Statement:
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