CSS with the same image and text center alignment

Source: Internet
Author: User
ArticleDirectory
    • Align text with the middle of the image
    • Align text with top image
    • Align text with the bottom of the image

It is often necessary to align the pictures and texts in a row. Although a lot of information has taken a lot of detours, a foreign website has seen the correct solution, let's share it with you. Please ignore it.

Align the image to the bottom of the text-usage:

This CSSCodeAlign the bottom of the image with the bottom of the text.

First, you should write the class of the CSS style file in the following format ):

. Textbottom {vertical-align: Text-bottom ;}

Then apply the class to the attributes of the image you want to align, for example (pay attention to the simhei part ):

Class = "textbottom"Alt = "portfolio more info tag">

In this way, the bottom of the image can be aligned with the bottom of the text. The core of this method is to use the text of the row as the benchmark, and then adjust the CSS style of the image to match the text to achieve the desired alignment.

For other image positions, CSS is used to align the text with the middle of the image.

If this effect is not obvious, open this page to see the icon before the link.

One page of Water View

Style:. Textmiddle {vertical-align: middle ;}

Align text with top image

One page of Water View

Style:. Texttop {vertical-align: Top ;}

Align text with the bottom of the image

One page of Water View

Style:. Textbaseline {vertical-align: baseline ;}

Core tips

The reason why I made a detour on such a simple thing is that I did not understand CSS and encountered an article that was wrong. Most of these articles describe such CSS code in the line to be aligned. As shown in the preceding exampleIn the CSS description of the image.. Yes, the Code has all been mentioned, that is, there is no explanation of where to put it.

How to say it? Is this because there is no CSS master in China? Certainly not! However, the results of searching in Chinese are similar to those directly copied from a specific place even if they are ranked first. They may not even be viewed. It's strange that Google is not making the best effort.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.