本文操作环境:windows7系统、HTML5&&CSS3版、Dell G3电脑。
纯css写带小三角对话框
在实际样式中经常会遇到要写类似对话框的样式,而这种样式往往会有一个小三角,如下所示:
示例图片
那么如何用css写出来呢,其实很简单,先让父元素相对定位,然后运用css的伪类before或after。就可以写个三角形,如果想要带边框的三角形,则可以两个重叠使用。代码如下:
复制代码1
2
3
<p class="box2">
纯css写带小三角对话框
</p>
登录后复制
复制代码1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
.box2{
float:left;
position:relative;
width:200px;
height:100px;
border:1px solid #00f;
margin:50px;
box-sizing:border-box;
font-size:14px;
padding:10px;
box-shadow:0 0 2px rgba(0,0,0,.5)
}
.box2:before,
.box2:after{
position:absolute;
content:'';
border:10px solid;
}
.box2:before{
right: -20px;
top:20px;
border-color: transparent transparent transparent #00f;
}
.box2:after{
border-color: transparent transparent transparent #fff;
right: -18px;
top: 20px;
}
登录后复制
推荐学习:css视频教程
以上就是css怎么实现对话框的详细内容,更多请关注靠谱客其它相关文章!
最后
以上就是标致老师最近收集整理的关于css怎么实现对话框的全部内容,更多相关css怎么实现对话框内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复