Home > Article > Web Front-end > Problem with img being centered in div
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.