文本类元素的特点以及多个图片之间有空隙

因为文本类元素的特点是能被文字分隔符分割,回车或者空格
比如img是行级块元素,inline-block带有inline属性的特点
下面这个例子,img标签之间有回车,图片就分开展示的

<!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>
 <img src="./d043ad4bd11373f02efb63adad0f4bfbfbed043f.png" alt="">
 <img src="./d043ad4bd11373f02efb63adad0f4bfbfbed043f.png" alt="">
 <img src="./d043ad4bd11373f02efb63adad0f4bfbfbed043f.png" alt="">
 <img src="./d043ad4bd11373f02efb63adad0f4bfbfbed043f.png" alt="">
</body>
<style>
    * {
     
     
        margin: 0;
        padding: 0;
    }
  img{
     
     
      width:300px                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  }
</style>

</html>

在这里插入图片描述
现在img之间不设置回车

<!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>
 <img src="./d043ad4bd11373f02efb63adad0f4bfbfbed043f.png" alt=""><img src="./d043ad4bd11373f02efb63adad0f4bfbfbed043f.png" alt=""><img src="./d043ad4bd11373f02efb63adad0f4bfbfbed043f.png" alt=""><img src="./d043ad4bd11373f02efb63adad0f4bfbfbed043f.png" alt="">
</body>
<style>
    * {
     
     
        margin: 0;
        padding: 0;
    }
  img{
     
     
      width:300px                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  }
</style>

</html>

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/x1037490413/article/details/108512940