简体   繁体   中英

HTML & CSS: How I can make an image's bottom edge align with text?

In my HTML pages I have text with img s. The top edge of the img is aligned with the top of the text, but I want the bottom of the img to be aligned with the text.

How can this be done?

UPDATE Now I see this is the default behaviour, but it doesn't happen in my page. What could possibly be wrong?

EDIT: I came back to add line breaks and decided to throw an example in, too.

You can do this with CSS's vertical-align property. Something like this:

<img src="wherever.png" style="vertical-align: text-top;" />

More information about the style is available at w3schools , where they have a neat sandbox .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM