首页 > 技术文章 > 纯css实现三角形

zuopin 2016-09-25 23:03 原文

两个三角形重叠,a作背景,b作边框,定位相差1px

<style type="text/css">
.message-box {
position: relative;
width: 240px;
height: 60px;
line-height: 60px;
background: #E9FBE4;
box-shadow: 1px 2px 3px #E9FBE4;
border: 1px solid #C9E9C0;
border-radius: 4px;
text-align: center;
color: #0C7823;
}
.triangle-border {
position: absolute;
left: 30px;
overflow: hidden;
width: 0;
height: 0;
border-width: 10px;
border-style: solid dashed dashed dashed;
}
.tb-border {
bottom: -20px;
border-color: #C9E9C0 transparent transparent transparent;
}
.tb-background {
bottom: -19px;
border-color: #E9FBE4 transparent transparent transparent;
}
</style>

<body>

<div class="message-box">
<div class="triangle-border tb-border"></div>
<div class="triangle-border tb-background"></div>
</div>
</body>

推荐阅读