CSS3之创建透明边框三角

Posted 一去丶二三里

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CSS3之创建透明边框三角相关的知识,希望对你有一定的参考价值。

简述

在前面,我们分享过关于三角的实现方式,主要根据border属性来设置,下面我们来实现上、下、左、右各种不同颜色的三角。

实现

效果

技术分享

源码

<!DOCTYPE html>
<html>
<head>
<style type=‘text/css‘>

/* 上三角 */
.arrow-up {
  width: 0;
  height: 0;
  border-left: 20px solid transparent;
  border-right: 20px solid transparent;
  border-bottom: 20px solid green;
}

/* 下三角 */
.arrow-down {
  width: 0;
  height: 0;
  border-left: 20px solid transparent;
  border-right: 20px solid transparent;
  border-top: 20px solid orange;
}

/* 右三角 */
.arrow-right {
  width: 0;
  height: 0;
  border-top: 60px solid transparent;
  border-bottom: 60px solid transparent;
  border-left: 60px solid blue;
}

/* 左三角 */
.arrow-left {
  width: 0;
  height: 0;
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  border-right: 10px solid silver;
}
</style>
</head>
<body>
  <div class="arrow-up"></div>
  <div class="arrow-down"></div>
  <div class="arrow-left"></div>
  <div class="arrow-right"></div>
</body>
</html>

代码比较简单,我就不过多阐述了!

以上是关于CSS3之创建透明边框三角的主要内容,如果未能解决你的问题,请参考以下文章

css3 这种半透明边框带阴影,里面填充白色该怎么做?

CSS3实现三角形

用CSS画一个带阴影的三角形的示例代码

用三角形创建一个三角形原理

CSS3之图像透明&不透明

CSS3之字形边框是如何制作的?