码迷,mamicode.com
首页 > 其他好文 > 详细

带三角缺口的边框

时间:2014-11-21 12:04:20      阅读:225      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   io   ar   color   os   sp   on   

以前看漫画的时候如果有对话内容,一般会有一个边框,然后带着一个三角从说话人的身上引出。类似下图这样:

bubuko.com,布布扣

应该有很多方法来实现,这里提供的办法就是创造一个边框,然后用两个三角覆盖。效果如下:

bubuko.com,布布扣

为了方便理解,我给body加了个黑色背景,是这样:

bubuko.com,布布扣

代码如下:

<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>带三角缺口的边框</title>
<style>
.out {
    display:block;
    width:0;
    height:0;
    border-left:6px dashed transparent;
    border-right:6px dashed transparent;
    border-top:0;
    border-bottom:7px solid #ccc;
    position:relative;
    top:-7px;
    left:50%;
}
.inner {
    position:absolute;
    border-left:6px dashed transparent;
    border-right:6px dashed transparent;
    border-top:0;
    border-bottom:7px solid #fff;
    left:-6px;
    top:2px;
}
div {
    position:relative;
    margin:0 auto;
    width:80px;
    height:100px;
    border:1px solid #ccc;
    border-radius:5px;
}
    
</style>
</head>

<body>
<div>
<span class="out">
    <span class="inner"></span>
</span>
</div>
</body>
</html>

 

带三角缺口的边框

标签:style   blog   http   io   ar   color   os   sp   on   

原文地址:http://www.cnblogs.com/xumingsong/p/4112285.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!