纯css实现各种箭头图片效果

我们经常会通过使用css来实现某些图片的来达到不使用真正意义上的图片的效果,今天就尝试着使用纯css来实现几个常见的箭头效果

下面的css都是使用在span标签上的

1.普通箭头

向上箭头

图片效果:

代码:

.normal_top_arrow {
  display: inline-block;
  width: 80px;
  height: 110px;
  box-shadow: 0px 0px 0px 25px #ffffff inset;
  background-color: #ff0000;
}
.normal_top_arrow::after {
  content: "";
  position: relative;
  top: -15px;
  border-bottom: 40px solid #ff0000;
  border-left: 40px solid transparent;
  border-right: 40px solid transparent;
}

向下箭头

图片效果:

代码:

.normal_bottom_arrow {
  display: inline-block;
  width: 80px;
  height: 110px;
  box-shadow: 0px 0px 0px 25px #ffffff inset;
  background-color: #ff0000;
}
.normal_bottom_arrow::after {
  content: "";
  position: relative;
  top: 100%;
  border-top: 40px solid #ff0000;
  border-left: 40px solid transparent;
  border-right: 40px solid transparent;
}

向左箭头

图片效果:

代码:

.normal_left_arrow {
  display: inline-block;
  width: 110px;
  height: 80px;
  box-shadow: 0px 0px 0px 25px #ffffff inset;
  background-color: #ff0000;
}
.normal_left_arrow::after {
  content: "";
  display: inline-block;
  border-right: 40px solid #ff0000;
  border-top: 40px solid transparent;
  border-bottom: 40px solid transparent;
}

向右箭头

图片效果:

代码:

.normal_right_arrow {
  display: inline-block;
  width: 110px;
  height: 80px;
  box-shadow: 0px 0px 0px 25px #ffffff inset;
  background-color: #ff0000;
}
.normal_right_arrow::after {
  content: "";
  display: inline-block;
  position: relative;
  left: 80px;
  border-left: 40px solid #ff0000;
  border-top: 40px solid transparent;
  border-bottom: 40px solid transparent;
}

2.斜向箭头

斜向箭头其实就将普通的箭头进行旋转,但是使用转向时阴影外会留出一个边框,我使用两个box-shadow向四个方向移动一个像素解决这个问题(可以试着把box-shadow逗号后面的部分代码去掉看看效果)

右下角箭头

图片效果:

代码:

.right_bottom_arrow {
  display: inline-block;
  width: 110px;
  height: 80px;
  box-shadow: -1px -1px 0px 25px #ffffff inset, 1px 1px 0px 25px #ffffff inset;
  background-color: #ff0000;
  transform: rotate(45deg);
}
.right_bottom_arrow::after {
  content: "";
  display: inline-block;
  position: relative;
  left: 80px;
  border-left: 40px solid #ff0000;
  border-top: 40px solid transparent;
  border-bottom: 40px solid transparent;
}

左下角箭头

图片效果:

代码:

.left_bottom_arrow {
  display: inline-block;
  width: 110px;
  height: 80px;
  box-shadow: -1px -1px 0px 25px #ffffff inset, 1px 1px 0px 25px #ffffff inset;
  background-color: #ff0000;
  transform: rotate(135deg);
}
.left_bottom_arrow::after {
  content: "";
  display: inline-block;
  position: relative;
  left: 80px;
  border-left: 40px solid #ff0000;
  border-top: 40px solid transparent;
  border-bottom: 40px solid transparent;
}

右上角箭头

图片效果:

代码:

.right_top_arrow {
  display: inline-block;
  width: 110px;
  height: 80px;
  box-shadow: -1px -1px 0px 25px #ffffff inset, 1px 1px 0px 25px #ffffff inset;
  background-color: #ff0000;
  transform: rotate(-45deg);
}
.right_top_arrow::after {
  content: "";
  display: inline-block;
  position: relative;
  left: 80px;
  border-left: 40px solid #ff0000;
  border-top: 40px solid transparent;
  border-bottom: 40px solid transparent;
}

左上角箭头

图片效果:

代码:

.left_top_arrow {
  display: inline-block;
  width: 110px;
  height: 80px;
  box-shadow: -1px -1px 0px 25px #ffffff inset, 1px 1px 0px 25px #ffffff inset;
  background-color: #ff0000;
  transform: rotate(-135deg);
}
.left_top_arrow::after {
  content: "";
  display: inline-block;
  position: relative;
  left: 80px;
  border-left: 40px solid #ff0000;
  border-top: 40px solid transparent;
  border-bottom: 40px solid transparent;
}

3.循环箭头

右循环箭头

图片效果:

代码:

.right_circle_arrow {
  display: inline-block;
  width: 100px;
  height: 100px;
  border: 20px solid #ff0000;
  border-radius: 50%;
}
.right_circle_arrow::after {
  content: "";
  position: relative;
  top: 65px;
  left: 65px;
  border-top: 40px solid #ff0000;
  border-left: 40px solid #ffffff;
  border-right: 40px solid #ffffff;
}

左循环箭头

图片效果:

 

代码:

.left_circle_arrow {
  display: inline-block;
  width: 100px;
  height: 100px;
  border: 20px solid #ff0000;
  border-radius: 50%;
}
.left_circle_arrow::after {
  content: "";
  position: relative;
  top: 65px;
  right: 45px;
  border-top: 40px solid #ff0000;
  border-left: 40px solid #ffffff;
  border-right: 40px solid #ffffff;
}

4.尖尾箭头

图片效果:

代码:

.sharp_arrow {
  display: inline-block;
  height: 0px;
  border-left: 40px solid #ff0000;
  border-top: 40px solid #ffffff;
  border-bottom: 40px solid #ffffff;
  transform: rotateZ(0deg);
}
.sharp_arrow::after {
  content: "";
  display: inline-block;
  position: relative;
  top: -20px;
  left: -120px;
  border-right: 80px solid #ff0000;
  border-top: 20px solid transparent;
  border-bottom: 20px solid transparent;
}

通过改变transform:rotateZ()里面的度数来实现不同方向的尖尾箭头

5.弧形尾箭头

左弧形尾箭头

图片效果:

代码:

.curve_left_darrow {
  position: relative;
  display: inline-block;
  width: 0;
  border-top: 90px solid transparent;
  border-left: 90px solid red;
  transform: rotate(10deg) translateX(100%);
}
.curve_left_darrow:after {
  content: "";
  position: absolute;
  border: 0 solid transparent;
  border-top: 40px solid #ff0000;
  border-radius: 0 120px 0 0;
  top: -120px;
  right: -90px;
  width: 120px;
  height: 120px;
  transform: rotate(-45deg);
}

右弧形尾箭头

图片效果:

代码:

.curve_right_darrow {
  position: relative;
  display: inline-block;
  width: 0;
  border-top: 90px solid transparent;
  border-right: 90px solid red;
  transform: rotate(10deg) translateX(100%);
}
.curve_right_darrow:after {
  content: "";
  position: absolute;
  border: 0 solid transparent;
  border-top: 40px solid #ff0000;
  border-radius: 120px 0 0 0;
  top: -120px;
  left: -90px;
  width: 120px;
  height: 120px;
  transform: rotate(45deg);
}

以上就是我找到的部分常用的箭头和它们的css实现代码,如果有什么有趣的箭头也希望大家说出来一起尝试实现。

  • 3
    点赞
  • 39
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值