p.speech:after{
content: ‘ ‘;
position: absolute;
width: 0;
height: 0;
left: 38px;
top: 100px;
border: 15px solid;
border-color: #fff transparent transparent #fff;
}
我们的不使用图片的对话气泡就完成了:
另外,我们还可以使用:before和:after伪类来做很多其他的事情,比如,一个思考气泡也可以通过这样办法完成:
首先也是建一个
CSS Code复制内容到剪贴板
<p class="thought">I think…</p>
css代码:
CSS Code复制内容到剪贴板
p.thought{
position: relative;
width: 130px;
height: 100px;
text-align: center;
line-height: 100px;
background-color: #fff;
border: 8px solid #666;
-webkit-border-radius: 58px;
-moz-border-radius: 58px;
border-radius: 58px;
-webkit-box-shadow: 2px 2px 4px #888;
-moz-box-shadow: 2px 2px 4px #888;
box-shadow: 2px 2px 4px #888;
}
CSS Code复制内容到剪贴板
p.thought:before, p.thought:after{
content: ”;
position: absolute;
left: 10px;
top: 70px;
width: 40px;
height: 40px;
background-color: #fff;
border: 8px solid #666;
-webkit-border-radius: 28px;
-moz-border-radius: 28px;
border-radius: 28px;
z-index:5;
}
CSS Code复制内容到剪贴板
p.thought:after{
position: absolute;
width: 20px;
height: 20px;
left: 5px;
top: 100px;
-webkit-border-radius: 18px;
-moz-border-radius: 18px;
border-radius: 18px;
z-index:6;
}
最新实现效果:










