Home  >  Article  >  Web Front-end  >  Problem with img being centered in div

Problem with img being centered in div

WBOY
WBOYOriginal
2016-09-27 14:05:211343browse

Img is an inline element. To set its margin attribute to center it, convert it to a block element display:block; and then use margin:0 auto; to achieve horizontal centering of the image; (Some designers add A div tag, and then center it through the margin of the div tag).

If the image is in the span attribute under the div, it must be converted to display: block; then padding-top: 10px.

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
Previous article:css positioningNext article:css positioning