jquery+css实现三款checkbox点击开关效果代码

代码语言:html

所属分类:表单美化

代码描述:jquery+css实现三款checkbox点击开关效果代码

代码标签: jquery css 三款 checkbox 点击 开关

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

<!DOCTYPE html>
<html lang="en" >
<head>
  <meta charset="UTF-8">
<style>
    /*fonts*/
@import url("https://fonts.googleapis.com/css2?family=Montserrat+Alternates:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap");
@import url("https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200");

.material-icons {
  font-family: "Material Icons";
  font-weight: normal;
  font-style: normal;
  font-size: 24px; /* Preferred icon size */
  display: inline-block;
  line-height: 1;
  text-transform: none;
  letter-spacing: normal;
  word-wrap: normal;
  white-space: nowrap;
  direction: ltr;

  /* Support for all WebKit browsers. */
  -webkit-font-smoothing: antialiased;
  /* Support for Safari and Chrome. */
  text-rendering: optimizeLegibility;

  /* Support for Firefox. */
  -moz-osx-font-smoothing: grayscale;

  /* Support for IE. */
  font-feature-settings: "liga";
}
.material-symbols-outlined {
  font-family: "Material Symbols Outlined";
  font-weight: normal;
  font-style: normal;
  font-size: 24px; /* Preferred icon size */
  display: inline-block;
  line-height: 1;
  text-transform: none;
  letter-spacing: normal;
  word-wrap: normal;
  white-space: nowrap;
  direction: ltr;
}

.material-symbols-outlined {
  font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 48;
}
* {
  margin: 0;
  padding: 0;
  font-family: Montserrat;
  color: #333;
}
body {
  height: 100vh;
  background: linear-gradient(45deg, blanchedalmond, aliceblue);
  background: linear-gradient(-45deg, #e6cece, #e6cece);
}
main {
  display: flex;
  flex-direction: column;
  place-content: center;
  align-items: center;
  height: 100%;
}
.checkbox-container {
  margin: 48px 32px;
  position: relative;
  display: flex;
  align-items: center;
}
label {
  margin-left: 16px;
  font-size: 20px;
}
input {
  cursor: pointer;
}

.container {
  border-radius: 8px;
  padding: 32px;
  backdrop-filter: blur(10px);
  box-shadow: -6px 14px 42px 0 #a28a8a;
  min-width: 50%;
  place-content: center;
  text-align: center;
  display: flex;
  background: #ffffff73;
}
/*toggle 1*/
.type-1 .toggle {
  background: transparent;
  width: 30px;
  height: 30px;
  border: 8px solid #666;
  transition: all ease-in-out 0.5s;
  position: absolute;
  top: 0;
}
.type-1.checked .toggle {
  background: transparent;
  width: 12px;
  height: 30px;
  border-top-color: transparent;
  border-left-color: transparent;
  transform: rotate(45deg);
  top: -8px;
}
.type-1 input {
  width: 48px;
  height: 48px;
  position: relative;
  top: 0;
  left: 0;
  cursor: pointer;
  opacity: 0;
}
.checkbox-container.checked * {
  color: #079baa;
  border-color: #079baa;
}

/*toggle 2*/
.type-2 .toggle {
  width: 45px;
  height: 15px;
  background: #555;
  border-radius: 12px;
  position: absolute;
  left: 0;
  transition: all ease 0.5s;
}
.checked.type-2 .toggle {
  background: #079baa;
}
.type-2 input {
  width: 45px.........完整代码请登录后点击上方下载按钮下载查看

网友评论0