css3实现各种奇形怪状按钮代码

801 ℃

css3实现各种奇形怪状按钮代码?下面web建站小编给大家分析一下梯形与平行四边形、矩形与圆角按钮、切角等各种图形。

1、梯形与平行四边形

复制代码<div class='btn parallelogram'>Parallelogram</div>
  • 1
复制代码.parallelogram {
  position: relative;
  width: 160px;
  height: 64px;
  &::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: #03f463;
    transform: skewX(15deg);
  }
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15

2、矩形与圆角按钮

复制代码<div class='btn rect'>rect</div>、
<div class='btn circle'>circle</div>
  • 1
  • 2
复制代码.btn {
  margin: 8px auto;
  flex-shrink: 0;
  width: 160px;
  height: 64px;
}
.rect {
  background: #f6ed8d;
}
.circle {
  border-radius: 64px;
  background: #7de3c8;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

3、切角

复制代码<div class="clip-notching">notching</div>
  • 1
复制代码.clip-notching {
  background: linear-gradient(
    45deg,
    #f9d9e7,
    #ff1493
  );
  clip-path: polygon(
    15px 0,
    calc(100% - 15px) 0,
    100% 15px,
    100% calc(100% - 15px),
    calc(100% - 15px) 100%,
    15px 100%,
    0 calc(100% - 15px),
    0 15px
  );
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17

4、箭头按钮

复制代码<div class="arrow">arrow</div>
  • 1
复制代码&.arrow {
  background: linear-gradient(
      -135deg,
      transparent 22px,
      #04e6fb 22px,
      #65ff9a 100%
    )
    top right,
    linear-gradient(
      -45deg,
      transparent 22px,
      #04e6fb 22px,
      #65ff9a 100%
    )
    bottom right;
  background-size: 100% 50%;
  background-repeat: no-repeat;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18

5、内切圆角

复制代码<div class="mask-inset-circle">inset-circle</div>
  • 1
复制代码.mask-inset-circle {
  background: linear-gradient(45deg, #2179f5, #e91e63);
  mask: radial-gradient(
    circle at 100% 100%,
    transparent 0,
    transparent 12px,
    #2179f5 13px
  ),
  radial-gradient(
    circle at 0 0,
    transparent 0,
    transparent 12px,
    #2179f5 13px
  ),
  radial-gradient(
    circle at 100% 0,
    transparent 0,
    transparent 12px,
    #2179f5 13px
  ),
  radial-gradient(
    circle at 0 100%,
    transparent 0,
    transparent 12px,
    #2179f5 13px
  );
  mask-repeat: no-repeat;
  mask-position: right bottom, left top, right top, left bottom;
  mask-size: 70% 70%;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30

6、圆角不规则矩形

复制代码<div class="skew">Skew</div>
  • 1
复制代码.skew {
  position: relative;
  width: 120px;
  &::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 10px;
    background: orange;
    transform: skewX(15deg);
  }
  &::before {
    content: "";
    position: absolute;
    top: 0;
    right: -13px;
    width: 100px;
    height: 64px;
    border-radius: 10px;
    background: orange;
  }
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25

7、圆角按钮

复制代码<div class="outside-circle">outside-circle</div>
  • 1
复制代码.outside-circle {
  position: relative;
  background: #e91e63;
  border-radius: 10px 10px 0 0;
  &::before {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    left: -20px;
    bottom: 0;
    background: #000;
    background:radial-gradient(circle at 0 0, transparent 20px, #e91e63 21px);
  }
  &::after {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    right: -20px;
    bottom: 0;
    background: #000;
    background:radial-gradient(circle at 100% 0, transparent 20px, #e91e63 21px);
  }
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25

总结:css3

渐变(线性渐变 linear-gradient、径向渐变 radial-gradient、多重渐变)

遮罩 mask

裁剪 clip-path

变形 transform

进入前端入门建站教程官网入口

css3中clip-path的属性语法介绍(裁剪范围计算)

span点击事件后实现点击事件禁用(类似按钮disabeld方法)

如何利用css语法控制文本显示行数

css如何去掉滚动条占用的高度

利用css实现文本的单行溢出省略和多行溢出省略

标签: clip-path, css, mask

上面是“css3实现各种奇形怪状按钮代码”的全面内容,想了解更多关于 前端知识 内容,请继续关注web建站教程。

当前网址:https://m.ipkd.cn/webs_2205.html

声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

js利用正则表达式对表单字段进行验证
JavaScript数组内合并根据相同key生成子数组
帝国cms技巧之内容页上一篇和下一篇另类调用方
vue语法中双击事件和单击事件出现冲突怎么解决
网站优化之如何快速提高网站的排名呢?