Picture and text alignment, the usage of vertical-align

vertical-align sets the vertical alignment of elements in a row, the attribute values ​​are:

baseline: aligned with the baseline
top: aligned with the top
middle: aligned with the middle
bottom: aligned with the bottom

There are pictures of different sizes before and after the text, and the attribute is baseline:

top:

bottom:

The most commonly used middle, the text will be aligned with the center of the two pictures:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        img {
            width: 200px;
            vertical-align: middle;
        }
    </style>
</head>
<body>
    <div>
        <img src="../img/3.jpg" alt="">
        123123123123123
        <img src="../img/2.jpg" alt="">
    </div>
</body>
</html>

 

Guess you like

Origin blog.csdn.net/xingxinglinxi/article/details/108650214