你能看看这个片段,让我知道为什么我不能在div之后添加内容
div{background:yellow; height:200px; width:200px;}
div:after {
content: "Content";
}

<div>
hi
</div>
&#13;
答案 0 :(得分:1)
div{
background:yellow;
height:200px;
width:200px;
position: relative;
}
#div1:after {
position: absolute;
content: "Content";
width: 100%;
height: 100%;
left: 100%;
background: #F1F2F3;
}
#div2:after {
position: absolute;
content: "Content";
width: 100%;
height: 100%;
left: 0%;
top: 100%;
background: #F1F2F3;
}
&#13;
<div id='div1'>
hi
</div>
<br/>
<div id='div2'>
hi2
</div>
&#13;
答案 1 :(得分:1)
您仍然可以达到您正在寻找的效果,您只需要更多的CSS来实际将新信息放置在您想要的位置。
div{background:yellow; height:200px; width:200px; position:relative}
div:after {
content: "Content";
position:absolute;
bottom: -20px;
}
但是,我同意@Jonathan的说法,单独的标记会更加清晰,特别是如果您计划像按钮一样进行交互。
答案 2 :(得分:0)
&#34; ::后&#34;插入元素的内容之后,而不是元素本身之后。
您需要创建另一个元素来保存评论
div{background:yellow; height:200px; width:200px;}
div.holder::after {
content: "Content";
}
&#13;
<div class="holder">
<div>
hi
</div>
</div>
&#13;