凹下去的白色按钮

news2024/10/6 14:28:25

先看效果:
在这里插入图片描述
再看代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>凹下去的按钮</title>
  <style>
    @import url("https://fonts.googleapis.com/css2?family=Comfortaa:wght@600&display=swap");
    :root {
      --highlight-left: 0;
      --pagination-width: 0;
    }

    html {
      height: 100%;
    }

    body {
      font-family: sans-serif;
      height: 100%;
      margin: 0;
      font-family: "Comfortaa", cursive;
      background-color: #eef3f7;
      user-select: none;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .radio-checked {
      position: relative;
      font-size: 34px;
      letter-spacing: 1px;
      box-shadow: -6px -5px 14px 3px #fff, 7px 7px 12px 2px #d0d8e3;
      border-radius: 70px;
    }
    .radio-checked_input {
      display: none;
    }
    .radio-checked_input:checked + .radio-checked_label--on {
      color: #47cf73;
      text-shadow: 0 0 7px rgba(71, 207, 115, 0.6);
    }
    .radio-checked_input:checked + .radio-checked_label--off {
      color: #ff3c41;
      text-shadow: 0 0 7px rgba(255, 60, 65, 0.6);
    }
    .radio-checked_input:checked + .radio-checked_label:before {
      display: none;
    }
    .radio-checked_label {
      cursor: pointer;
      display: inline-block;
      padding: 20px 25px 15px;
      line-height: 1;
      border-radius: 3rem;
      color: #acb2c0;
      transition: all 150ms ease-in-out;
    }
    .radio-checked_label:before {
      content: "";
      position: absolute;
      left: 0;
      top: 0;
      right: 0;
      bottom: 0;
      display: block;
    }
    .radio-checked_container {
      position: relative;
    }
    .radio-checked_highlight {
      position: absolute;
      left: 0;
      bottom: 0;
      width: var(--pagination-width);
      height: 100%;
      border-radius: 70px;
      box-shadow: inset -5px -5px 10px 4px #fff, inset -2px 6px 8px 6px #d0d8e3;
      background: #eef3f7;
      transition: all 0.6s ease;
      transform: translateX(var(--highlight-left));
    }

    .svg {
      position: absolute;
      top: -50%;
      bottom: -50%;
      pointer-events: none;
    }
    .svg_icon {
      width: auto;
      height: 100%;
    }
    .svg--right {
      left: 100%;
    }
    .svg--left {
      right: 100%;
    }
  </style>
</head>
<body>
<div class="radio-checked">
  <div class="radio-checked_highlight"></div>
  <div class="radio-checked_container">
    <input checked="checked" class="radio-checked_input" id="on" name="status" type="radio" value="on" /><label class="radio-checked_label radio-checked_label--on" for="on"> On</label><input class="radio-checked_input" id="off" name="status" type="radio" value="off" /><label class="radio-checked_label radio-checked_label--off" for="off">Off</label>
  </div>
</div>
</body>
<script>
  let root = document.documentElement;
  let color = ["#47cf73", "#7f71fe", "#1A3AF8", "#47cf73"];
  var animateDur = "1.4s";

  window.onload = function () {
    let activeChecked = document.querySelector(
            ".radio-checked_input:checked + .radio-checked_label"
    );
    let left = activeChecked.offsetLeft;
    let width = activeChecked.offsetWidth;
    animation(left, width);
  };

  document
          .querySelectorAll(".radio-checked_label")
          .forEach((t) => t.addEventListener("click", onChecked));

  function onChecked(e) {
    let left = e.target.offsetLeft;
    let width = e.target.offsetWidth;
    animation(left, width);
  }
  var bool = true;
  function animation(left, width) {
    root.style.setProperty("--pagination-width", width + "px");
    root.style.setProperty("--highlight-left", left + "px");
    (bool = !bool) ? svgCreate("right") : svgCreate("left");
  }

  function svgCreate(position) {
    let svgLeft =
            `<svg class="svg_icon" fill="none" viewBox="0 0 132 140" xmlns="http://www.w3.org/2000/svg">
<path d="M110 50.4209L68.7302 25.4209" id="Line1"/>
<path d="M110 59.498L45.9597 54.498" id="Line2"/>
<path d="M110 70.4824L46.1323 87.4824" id="Line3"/>
<path d="M110 79.3584L73.3484 113.358" id="Line4"/>
<path d="M110 73.4473L34.2236 110.447" id="Line5"/>
<path d="M110 64.499L24.0356 70.499" id="Line6"/>
<path d="M110 54.4736L39.8398 31.4736" id="Line7"/>
<path d="M110 56.4893L23.8953 38.4893" id="Line8"/>
<path d="M110 67.4893L21.1013 85.4893" id="Line9"/>
<path d="M110 85.2861L85.4102 118.286" id="Line10"/>
<path d="M110 76.4111L50.2839 116.411" id="Line11"/>
<path d="M110 61.4995L18.9907 59.4307" id="Line12"/>

		<g> <g> <g class="svg_obj"> <path d="M14.6324 5.25L20.9832 16.25C21.5606 17.25 20.8389 18.5 19.6842 18.5H6.98249C5.82778 18.5 5.10609 17.25 5.68344 16.25L12.0343 5.25C12.6116 4.25 14.055 4.25 14.6324 5.25Z" fill="none" stroke-linecap="square" stroke-linejoin="round" stroke-width="3" stroke=` +
            color[Math.floor(Math.random() * 4)] +
            `></path>
		</g> <animateMotion begin="0s" dur=` +
            animateDur +
            ` repeatCount="1"> <mpath xlink:href="#Line` +
            Math.floor(Math.random() * 6 + 6) +
            `"></mpath> </animateMotion> </g> </g> <g> <g> <g class="svg_obj"> <circle cx="12" cy="11" r="6.5" stroke-width="3" stroke=` +
            color[Math.floor(Math.random() * 4)] +
            `></circle> </g> <animateMotion begin="0s" dur=` +
            animateDur +
            ` repeatCount="1"> <mpath xlink:href="#Line` +
            Math.floor(Math.random() * 12 + 1) +
            `"></mpath> </animateMotion> </g> </g>
		 <g> <g> <g class="svg_obj"> <circle cx="12" cy="11" r="6.5" stroke-width="3" stroke=` +
            color[Math.floor(Math.random() * 4)] +
            `></circle> </g> <animateMotion begin="0s" dur=` +
            animateDur +
            ` repeatCount="1"> <mpath xlink:href="#Line` +
            Math.floor(Math.random() * 6 + 1) +
            `"></mpath> </animateMotion> </g> </g>
		 <g> <g> <g class="svg_obj"> <circle cx="12" cy="11" r="6.5" stroke-width="3" stroke=` +
            color[Math.floor(Math.random() * 4) + 1] +
            `></circle> </g> <animateMotion begin="0s" dur=` +
            animateDur +
            ` repeatCount="1"> <mpath xlink:href="#Line` +
            Math.floor(Math.random() * 12 + 1) +
            `"></mpath> </animateMotion> </g> </g>
		</svg>`;
    let svgRight =
            `<svg class="svg_icon" fill="none" viewBox="0 0 132 140"  xmlns="http://www.w3.org/2000/svg" >
<path d="M20 54.6191L64.6763 20.6191" id="Line13"/>
<path d="M20 56.5518L97.7788 20.5518" id="Line14"/>
<path d="M20 58.5176L90.8684 40.5176" id="Line15"/>
<path d="M20 63.5L111.989 61.5" id="Line16"/>
<path d="M20 69.5029L100.053 77.5029" id="Line17"/>
<path d="M20 73.5166L105.127 94.5166" id="Line18"/>
<path d="M20 77.5479L91.2126 108.548" id="Line19"/>
<path d="M20 80.6191L58.3235 108.619" id="Line20"/>
<path d="M20 83.7598L42.4385 114.76" id="Line21"/>
<path d="M20 66.5L98.0205 69.5" id="Line22"/>
<path d="M20 60.5049L102.93 49.5049" id="Line23"/>
<path d="M20 75.5303L83.1702 96.5303" id="Line24"/>

		<g> <g> <g class="svg_obj"> <path d="M14.6324 5.25L20.9832 16.25C21.5606 17.25 20.8389 18.5 19.6842 18.5H6.98249C5.82778 18.5 5.10609 17.25 5.68344 16.25L12.0343 5.25C12.6116 4.25 14.055 4.25 14.6324 5.25Z" fill="none" stroke-linecap="square" stroke-linejoin="round" stroke-width="3" stroke="#d0d8e3"></path>
		</g> <animateMotion begin="0s" dur=` +
            animateDur +
            ` repeatCount="1"> <mpath xlink:href="#Line` +
            Math.floor(Math.random() * 12 + 13) +
            `"></mpath> </animateMotion> </g> </g>

		<g> <g> <g class="svg_obj"> <path d="M17.2394 3L7.6162 18.2116M5 5.51355L20.2116 15.1367" stroke="#ff3c41" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/> </g> <animateMotion begin="0s" dur=` +
            animateDur +
            ` repeatCount="1"> <mpath xlink:href="#Line` +
            Math.floor(Math.random() * 12 + 13) +
            `"></mpath> </animateMotion> </g> </g>
		<g> <g> <g class="svg_obj"> <path d="M17.2394 3L7.6162 18.2116M5 5.51355L20.2116 15.1367" stroke="#acb2c0" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/> </g> <animateMotion begin="0s" dur=` +
            animateDur +
            ` repeatCount="1"> <mpath xlink:href="#Line` +
            Math.floor(Math.random() * 12 + 13) +
            `"></mpath> </animateMotion> </g> </g>
		</svg>`;

    let span = document.createElement("span");
    let radioChecked = document.querySelector(".radio-checked");
    span.className = "svg svg--" + position;
    if (position === "left") {
      span.innerHTML = svgLeft;
    } else {
      span.innerHTML = svgRight;
    }

    setTimeout(function () {
      radioChecked.appendChild(span);
    }, 400);
    setTimeout(function () {
      span.remove();
    }, 1500);
  }

</script>
</html>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/669810.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

【SIGMOD 2023】深度学习弹性数据流水线系统GoldMiner,大幅提升任务和集群效率

第一板块&#xff1a;开篇 近日&#xff0c;阿里云机器学习平台PAI和北京大学杨智老师团队合作的论文《GoldMiner: Elastic Scaling of Training Data Pre-Processing Pipelines for Deep Learning》被数据库领域顶会SIGMOD 2023接收。 GoldMiner观察到深度学习任务中的数据预…

redis登录常见报错

第一次接触redis登录的时候遇见几个报错 一、使用以下两个命令报错&#xff1a; ./redis-cli -h 127.0.0.1 -p 6380 ./redis-cli -p 6380 报错&#xff1a;Could not connect to Redis at 127.0.0.1:6380: Connection refused 应该和redis.conf中配置的bind字段的IP有关…

一文全揽C/C++中所有指针相关知识点(从原理到示例,学不完根本学不完!!!!)

本篇会对C/C中【常见指针相关知识】一直进行总结迭代&#xff0c;记得收藏吃灰不迷路&#xff0c;一起学习分享喔 请大家批评指正&#xff0c;一起学习呀~ 一、指针基本知识1.1 指针的定义1.2 &#xff08;*&#xff09; 和&#xff08; &&#xff09; 运算符1.3 如何声明…

SM国密算法(四) -- SM3算法

一、简介 SM3密码杂凑算法是中国国家密码管理局2010年公布的中国商用密码杂凑算法标准。适用于商用密码应用中的数字签名和验证。 SM3是在[SHA-256]基础上改进实现的一种算法&#xff0c;其安全性和SHA-256相当。SM3和MD5的迭代过程类似&#xff0c;也采用Merkle-Damgard结构。…

OpenCV(图像处理)-基于python-滤波器(低通、高通滤波器的使用方法)

1.概念介绍2. 图像卷积filter2D() 3. 低通滤波器3.1 方盒滤波和均值滤波boxFilter()blur() 3.2 高斯滤波&#xff08;高斯噪音&#xff09;3.3 中值滤波&#xff08;胡椒噪音&#xff09;3.4 双边滤波 4. 高通滤波器4.1Sobel&#xff08;索贝尔&#xff09;&#xff08;高斯&am…

STL之set和map

目录 一. 原型二. 模板参数适配三. 迭代器四. 插入函数的修改四. 代码 一. 原型 简单实现的红黑树 template<class K, class V> struct RBTreeNode {RBTreeNode<K, V>* _left;RBTreeNode<K, V>* _right;RBTreeNode<K, V>* _parent;pair<K, V> …

FPGA_学习_11_IP核_RAM_乒乓操作

本篇博客学习另一个IP核&#xff0c;RAM。 用RAM实现什么功能呢&#xff1f; 实现乒乓操作。 乒乓操作是什么呢&#xff1f; 参考&#xff1a; FPGA中的乒乓操作思想_fpga中乒乓操作的原因_小林家的龙小年的博客-CSDN博客 何为乒乓操作_fanyuandrj的博客-CSDN博客 以下是本人理…

Clion开发STM32之日志模块(参考RT-Thread)

前言 日志对于开发和排错方面有着很重要的影响。通过查看RT-Thread的源码&#xff0c;将日志的打印输出划分到具体的文件和通过宏定义对具体的日志等级进行划分&#xff0c;这样就比较方便。结合此源码的形式将其分离出来&#xff0c;作为自己项目的日志框架进行使用分为日志驱…

crossover软件下载2023最新版虚拟机

在Mac系统中一直存在一个比较令用户们头疼的问题&#xff0c;那就是安装不了想要的Windows软件。如果使用的第一台电脑就是MacBook那接触到的Windows软件想必并不是很多。但我们中的大多数人都是从小先学习了Windows的操作系统&#xff0c;再过渡到Mac系统上的。 那有小伙伴会…

最新基于MATLAB 2023a的机器学习、深度学习实践应用

MATLAB 2023版的深度学习工具箱&#xff0c;提供了完整的工具链&#xff0c;使您能够在一个集成的环境中进行深度学习的建模、训练和部署。与Python相比&#xff0c;MATLAB的语法简洁、易于上手&#xff0c;无需繁琐的配置和安装&#xff0c;能够更快地实现深度学习的任务。 M…

Flink流批一体计算(4):Flink功能模块

目录 Flink功能架构 Flink输入输出 Flink功能架构 Flink是分层架构的分布式计算引擎&#xff0c;每层的实现依赖下层提供的服务&#xff0c;同时提供抽象的接口和服务供上层使用。 Flink 架构可以分为4层&#xff0c;包括Deploy部署层、Core核心层、API层和Library层 部署层…

基于SSM的宠物领养系统的设计与实现

1.引言 动物作为人类的宠物已经有几千年的历史了&#xff0c;尤其是猫和狗因其天性被人类所喜爱和推崇&#xff0c;好多的成语故事、俗语等都及它们有关。但是&#xff0c;近几年来由于生活节奏的加快&#xff0c;人们的压力增大&#xff0c;没有时间和空间去照顾宠物&#xf…

ProGuard 进阶系列(三) Java 类文件解析

书接上文&#xff0c;当我们从用户的配置文件中读取到所有的配置信息后&#xff0c;下一步便是将配置中的指定的类文件进行读取&#xff0c;构建需要混淆的 Java 类文件的语法树。在阅读类文件之前&#xff0c;先来看一下输入输出参数中的内容&#xff0c;我使用的是一个 Andro…

大一下暑期计划 + 2023字节青训营预告直播

目录 &#x1f33c;前言 &#x1f339;后端学习方法 &#x1f333;1&#xff0c;层次 &#x1f333;2&#xff0c;体系 &#x1f333;3&#xff0c;算法和数据结构 &#x1f333;4&#xff0c;总结 &#x1f339;前端学习方法 &#x1f333;基础 &#x1f339;求职中如…

如何在Microsoft Excel中使用LEN函数

如果你曾经想尝试查找一行文本中的字符数&#xff0c;你可以使用Microsoft Excel来查找&#xff0c;这要归功于LEN函数。以下是如何使用它。 一、什么是 LEN 函数 LEN函数是一个简单的计算函数&#xff0c;用于计算给定文本字符串中的所有字符&#xff0c;包括数字、字母、特…

【数据库课设】图书馆资源管理系统 源码+流程图+结构设计(借还图书 逾期罚款 图书管理 读者管理 信息查询)python实现

文章目录 一 实现功能&#xff08;1&#xff09;管理员功能&#xff08;2&#xff09;读者功能 二 数据流图三 概念结构设计四 文件目录五 源码&#xff1a;main.py六 运行截图 一 实现功能 &#xff08;1&#xff09;管理员功能 一个管理员编号对应一个密码&#xff0c;且需…

redis—安装以及可视化

前言 redis 是一种非关系型数据库&#xff0c;什么是非关系型数据库&#xff0c;之前我们在mysql专栏 也有提到过&#xff0c;这边就不再过多的赘述&#xff0c;忘记了的小伙伴可以再次阅读这篇文章 终于明白了数据库的【关系型】与【非关系型】 其实这还是挺重要的&#xff…

ruoyi+vue回显数字的问题,解决方案

在项目中用ruoyi框架和前端vue进行开发&#xff0c; 需求是在前端生成下拉框&#xff0c;下拉框中的内容需要调用后端接口进行数据返回&#xff0c; 现在新增的时候&#xff0c;数据已经返回了&#xff0c;但是再修改的时候&#xff0c;进行回显数据导致前端列表中展示出来的…

城市排水监测系统为城市排水防涝提质增效

城市化进程中&#xff0c;城市排水系统成为城市基础设施建设的重要组成部分。然而&#xff0c;随着气候变化和城市建设规模的扩大&#xff0c;极端天气和内涝风险不断增加&#xff0c;城市的排水系统面临巨大挑战。因此&#xff0c;建立一套智能化城市排水监测系统&#xff0c;…

【python】一些常用的pandas技巧

有了gpt之后&#xff0c;确实很多代码都可以让gpt给改错。嘎嘎香 merge多个dateframe https://stackoverflow.com/questions/44327999/how-to-merge-multiple-dataframes data_net [a,b,c,d] net_merged reduce(lambda left,right: pd.merge(left,right,on[key column],ho…