Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize the text in the same row with the picture and the vertical center of the text in CSS

Shulou Source: shulou.com Published: 2022-06-01 11:05:25 10月04日 Update

This article mainly introduces CSS how to achieve text and picture in the same row and text vertical center of the relevant knowledge, the content is detailed and easy to understand, simple and fast operation, has a certain reference value, I believe that after reading this CSS how to achieve text and picture in the same row and text vertical center article will have a harvest, let's take a look at it.

The DIV+CSS instance code is as follows:

DIV+CSS instance teaches test body {font-size:12px;}

我是高度为37的CSS5图片

CSS5 test pen and ink CSS

First of all, we set the name of the text css in the body of this page to 12px. Then introduce the image in html (expansion: CSS introduces-CSS reference) and several test ink after the image. You can copy the above code to create a new html page, and then go to the hunter to browse the new page, after all, it will be like the picture above.

Set up equipment and equipment css so that calligraphy and pictures in the same row when the bump vertical center we are only important in the CSS color, involved in the CSS code below: img {vertical-align:middle;} participate in the above picture setting bump center CSS pattern can be in the same row of calligraphy and picture vertical center.

The complete DIV+CSS code is as follows:

CSS example description Note Test body {font-size:12px;} img {vertical-align:middle;}

我是高度为37的CSS5图片

CSS5 test calligraphy

We can either review the above picture or I can easily copy the above incomplete css code and html source code (source code) to achieve the ability to center vertically with the operation control css.

DIV CSS stretch and progress assume that we configure the height of ".yangshi" with line-height, if we want to center the content vertically in this DIV, we can set vertical-align:middle, CSS code as follows: .yangshi img {vertical-align:middle;} it is worth saying that the height and line-height are not necessarily greater than the picture height, otherwise "CSS HACK" will not be compatible in different browsers.

This is the end of the article on "how to achieve the same row of text and picture and vertical center of text up and down" in CSS. Thank you for reading! I believe that everyone has a certain understanding of the knowledge of "how to achieve the same row of text and pictures and vertical center of text up and down" in CSS. If you want to learn more, you are welcome to follow the industry information channel.

Tags: Pictures text code up and down tests content examples knowledge web pages calligraphy height above picture bump copy source code pen and ink articles browsing important value Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Shulou Information Microsoft Xiaomi MariaDB