18910140161

为什么使用pseduo类时不显示背景图像?

顺晟科技

2021-09-13 12:37:14

191

使用pseduo类时不显示背景图像?我正在尝试tike这个

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Static Template</title>
    <style>
      .abc {
        /* background: url("./a.png"); */
        /* height: 200px;
        width: 200px; */
      }

      .abc::before {
        content: "";
        background: url("./a.png");
        height: 200px;
        width: 200px;
      }
    </style>
  </head>
  <body>
    <!-- <div style="background: url('./a.png'); height: 200px; width: 200px;"></div> -->
    <div class="abc">ddd</div>
  </body>
</html>

我添加了一个带有pseduo类的类abc。但它不会显示我的背景图像?


顺晟科技:

必须应用display属性。

.abc { /* background: url("./a.png"); */ /* height: 200px; width: 200px; */ } .abc::before { content: ""; background:url(https://s3.amazonaws.com/images.seroundtable.com/google-black-1545140719.jpg); display:block; height: 200px; width: 200px; } <div class="abc">ddd</div>

  • TAG:
相关文章
我们已经准备好了,你呢?
2024我们与您携手共赢,为您的企业形象保驾护航