























这是一个创建于 1266 天前的主题,其中的信息可能已经有所发展或是发生改变。
这个是我的代码, 如果.square 移除 flex 特性, before 就看不见了, 为什么会这样? 我查了 mdn 没找到相关的内容
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
.square {
width: 100px;
height: 100px;
background-color: blue;
color: white;
/* 如果去掉这个 flex before 就看不见了 */
display: flex;
}
.square::before {
content: "";
width: 50px;
height: 50px;
background: lightgreen;
}
.square::after {
content: "";
}
.text::before{
content: "t1";
color: red;
}
.text::after{
content: "t2";
color: red;
}
</style>
</head>
<body>
<div class="square"></div>
<p class="text">love</p>
</body>
</html>
1 renmu 2022 年 12 月 26 日 via Android.square::before{ 行内文本你不能设置宽高,又没内容,就不显示了。 |
2 liyang5945 2022 年 12 月 26 日 via Android伪元素默认 display 是 inline |
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。