About the problem of vertical centering of img and span in div

About the problem of vertical centering of img and span in div

As shown below:

XML/HTML CodeCopy content to clipboard
  1. < html >   
  2. < head >   
  3. < style >   
  4. #test *{vertical-align:middle;}
  5. </ style >   
  6. < body >   
  7. < div   
  8. id = "test" >   
  9. < img   
  10. src = "http://127.0.0.1:7001/wsc/images/message.png" />   
  11. < span > sdfhsdhfdksfjhtes: </ span >   
  12. </ div >   
  13. </ body >   
  14. </ html >   

Please note: #test *{vertical-align:middle;}s

#test * represents all the elements in div, including inline elements such as span, input, and img.

vertical-align
Initial value: baseline (default value)
Inheritable: No Applicable to: Inline elements Description: vertical-align:baseline aligns the baseline of the element with the baseline of the parent element.
Warning: vertical-align does not affect the alignment of content within table cells, nor does it affect the alignment of content within block elements.

Please note: vertical-align only affects inline elements, such as span, img, em, input, a, etc., but is invalid for block elements such as div, h3, p, etc.

The above is all the content about the problem of vertical centering of img and span in div brought to you by the editor. I hope it will be helpful to you. Please support 123WORDPRESS.COM~

<<:  3 solutions to make your website support old versions of IE6, 7, 8, and 9 browsers

>>:  Can asynchrony in JavaScript save await?

Recommend

Detailed tutorial on installing mysql-8.0.20 under Linux

** Install mysql-8.0.20 under Linux ** Environmen...

Box-shadow and drop-shadow to achieve irregular projection example code

When we want to add a shadow to a rectangle or ot...

Detailed explanation of EXT series file system formats in Linux

Linux File System Common hard disks are shown in ...

Five delay methods for MySQL time blind injection

Five delay methods for MySQL time blind injection...

A brief analysis of MySQL explicit type conversion

CAST function In the previous article, we mention...

How to use wangEditor in vue and how to get focus by echoing data

Rich text editors are often used when doing backg...

Pure CSS to achieve cool neon light effect (with demo)

I have recently been following the CSS Animation ...

Implement MySQL read-write separation and load balancing based on OneProxy

Introduction Part 1: Written at the beginning One...

Practical example of Vue virtual list

Table of contents Preface design accomplish summa...

Use CSS variables to achieve cool and amazing floating effects

Recently, I found a fun hover animation from the ...