css空心三角形箭头矩形效果

快乐打工仔 分类:实例代码

分享一段代码实例,它实现了带有三角形箭头的矩形效果。

箭头是空心的,代码实例如下:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="http://www.pipipi.net/" />
<title>犀牛前端部落</title>
<style>
/*提示框*/
.msg {
  position: relative;
  width: 200px;
  height: 100px;
  border: 1px solid #ccc;
  box-shadow: 0 0 10px 2px #ccc;
}
.msg .triangle {
  position: absolute;
  top: 100%;
  left: calc((100% - 10px) / 2);
  width: 0;
  height: 0;
  border: 10px solid transparent;
  border-top-color: #ccc;
}
.msg .triangle:after {
  content: "";
  position: absolute;
  top: -11px;
  left: -9px;
  width: 0;
  height: 0;
  border: 9px solid transparent;
  border-top-color: white;
}
</style>
</head>
<body>
  <div class="msg">
    <div class="triangle"></div>
  </div>
</body>
</html>

回复

我来回复
  • 暂无回复内容