我是靠谱客的博主 酷酷烧鹅,这篇文章主要介绍利用css的before和after属性,实现类似QQ对话框效果,现在分享给大家,希望可以做个参考。

实现效果如下:


前面的小三角形的原理是利用两个三角形,一个是黑色,一个白色,利用index属性,让白色的三角形覆盖黑色的三角形,白色三角形比黑色三角形靠右1px。下面是代码:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
p:before{content: "H"}
p:after{content: "d"}
.test-div{
position: relative;
width: 150px;
height: 36px;
border-radius: 5px;
border: 1px solid black;
background: rgba(245, 245, 245, 1);
}
.test-div:before, .test-div:after {
content: "";
display:block;
position: absolute;
top: 8px;
width: 0;
height: 0;
border: 6px solid transparent;
}
.test-div:before {
left: -11px;
border-right-color: rgba(245, 245, 245, 1);
z-index: 1;
}
.test-div:after {
left: -12px;
border-right-color: rgba(0, 0, 0, 1);
z-index: 0;
}
</style>
</head>
<body>
<div class="test-div"><p>ello worl</p></div>
</body>
</html>



最后

以上就是酷酷烧鹅最近收集整理的关于利用css的before和after属性,实现类似QQ对话框效果的全部内容,更多相关利用css内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(135)

评论列表共有 0 条评论

立即
投稿
返回
顶部