Line-level block elements or text-type elements contain text, and the outside text will be aligned

When line-level block elements and text-type elements do not contain text, the outer text is aligned with its bottom

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <span></span>123
</body>
<style>
    * {
     
     
        margin: 0;
        padding: 0;
    }
   span{
     
     
       display: inline-block;
       width: 100px;
       height: 100px;
       background-color: pink;
   }
</style>

</html>

Insert picture description here
If there is text in the span, it will be aligned with the text in it
Insert picture description here

Adjust the alignment of a row of elements

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <span>123</span>123
</body>
<style>
    * {
     
     
        margin: 0;
        padding: 0;
    }
   span{
     
     
       display: inline-block;
       width: 100px;
       height: 100px;
       background-color: pink;
       vertical-align:50px;
   }
</style>

</html>

Insert picture description here

Guess you like

Origin blog.csdn.net/x1037490413/article/details/108513202