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

Summary of common problems and application skills in MySQL

Preface In the daily development or maintenance o...

A brief discussion on the implementation of fuzzy query using wildcards in MySQL

In the MySQL database, when we need fuzzy query, ...

How to add Vite support to old Vue projects

1. Introduction I have taken over a project of th...

Method of using MySQL system database for performance load diagnosis

A master once said that you should know the datab...

Teach you how to use webpack to package and compile TypeScript code

TypeScript Bundling webpack integration Usually, ...

Practice using Golang to play with Docker API

Table of contents Installing the SDK Managing loc...

Method example of safely getting deep objects of Object in Js

Table of contents Preface text parameter example ...

The basic principles and detailed usage of viewport

1. Overview of viewport Mobile browsers usually r...

MySQL obtains the current date and time function example detailed explanation

Get the current date + time (date + time) functio...

Ubuntu 20.04 Chinese input method installation steps

This article installs Google Input Method. In fac...

Realize three-level linkage of year, month and day based on JavaScript

This article shares the specific code for JavaScr...

How to quickly deploy Gitlab using Docker

1. Download the gitlab image docker pull gitlab/g...