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

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        /* 行内元素不能设置宽高,以此排列
        块级元素独占一行,可以设置宽高
        行内块以此排列,可以设置宽高 */
        
        div::before {
            content: "我是";
            background-color: coral;
            height: 100px;
            width: 100px;
            /* 转化为行内块,可以设置宽高 */
            display: inline-block;
        }
        
        div::after {
            content: "国人";
            background-color: coral;
            height: 100px;
            width: 100px;
            /* 转化为行内块,可以设置宽高 */
            display: inline-block;
        }
    </style>
</head>

<body>
    <!-- 
        伪元素选择器
        ::before     在元素内部前面插入一个行内元素
        ::after      在元素内部后面插入一个行内元素
        必须有 content 属性
        会创建一个行内元素 
    -->

    <div></div>

</body>

</html>

 

相关文章:

  • 2021-08-22
  • 2021-11-13
  • 2022-02-01
  • 2021-12-07
  • 2022-12-23
  • 2021-11-07
  • 2022-12-23
  • 2021-11-14
猜你喜欢
  • 2021-06-14
  • 2021-09-14
  • 2022-01-28
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案