前几天在代码中用了CSS中的:before,发现使用:before的标签及其下面的子标签全都自动加上了:before,代码大概如下:
HTML
<div calss="main">
<div class="title">
<div class="name">文章1</div>
</div>
<div class="desc"></div>
</div>
CSS
.main {
position: relative;
width: 100px;
height: 10px;
line-height: 10px;
cursor: pointer;
}
.main :before {
content: "";
width: 0;
height: 0;
border: 1px solid green;
}
究其原因,竟然是.main和:before之间不能有空格!!!