svg+css实现三种图标点击状态变化动画效果代码

代码语言:html

所属分类:动画

代码描述:svg+css实现三种图标点击状态变化动画效果代码,包含点赞、手册、金币支付三种图标。

代码标签: svg css 三种 图标 点击 状态 变化 动画

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="zh-CN">

<head>

 
<meta charset="UTF-8">
 
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">

<style>
    :root {
  /* 自定义颜色变量 方便统一切换图标颜色 */
  --color: #fb7299;
  /* --color: #00aeec; */
}
* {
  /* 初始化基础元素 */
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  /* 解决手机浏览器点击有选框的问题 */
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
body {
  /* 上下左右居中 */
  display: flex;
  justify-content: center;
  align-items: center;
  /* 元素的距离 */
  gap: 100px;
  /* 临时改成竖着居中 */
  /* flex-direction: column; */
  /* 超出部分隐藏 */
  overflow: hidden;

  min-height: 100vh;
}

.box {
  /* 内部元素上下左右居中 */
  display: flex;
  justify-content: center;
  align-items: center;

  width: 200px;
  height: 200px;
  /* 50% 的圆角就是 ○ */
  border-radius: 50%;
  /* 鼠标放上去是小手 */
  cursor: pointer;

  position: relative;
}

.box .icon {
  width: 150px;
  height: 150px;

  /* svg 的填充颜色 */
  fill: #ddd;
  /* svg 的描边线宽 */
  stroke-width: 1;
  /* svg 的描边颜色 */
  stroke: var(--color);
  /* svg 的描边线框样式 */
  stroke-dasharray: 100;
  /* svg 的描边偏移量,也就是描边开始到结束的距离 */
  stroke-dashoffset: 100;
  /* svg 的描边两头的形状,是圆的 */
  stroke-linecap: round;

  z-index: 10;
}

.box span,
.box span::before {
  width: 20px;
  height: 20px;
  background-color: transparent;
  border-radius: 50%;
  /* 利用盒子阴影来实.........完整代码请登录后点击上方下载按钮下载查看

网友评论0