svg+css实现自定义checkbox选中图标美化效果代码

代码语言:html

所属分类:表单美化

代码描述:svg+css实现自定义checkbox选中图标美化效果代码

代码标签: svg css 自定义 checkbox 选中 图标 美化

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


<!DOCTYPE html>
<html lang="en" >

<head>

  <meta charset="UTF-8">
  

  
  
  
<style>
@import url("https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;500&display=swap");
body {
  height: 100vh;
  display: flex;
  margin: 0;
  justify-content: center;
  align-items: center;
  font-family: "Open Sans", sans-serif;
}

.container {
  padding: 12em 0em;
}

.check {
  position: relative;
  margin-bottom: 16px;
  overflow: hidden;
  padding: 0em 0.5em;
}
.check input[type=checkbox] {
  position: absolute;
  left: -100%;
  transform: translateX(-100%);
}
.check input[type=checkbox]:focus-visible + label {
  outline: 2px solid #04a3ef;
  outline-offset: 3px;
}
.check input[type=checkbox]:active + label {
  top: 2px;
  position: relative;
}
.check input[type=checkbox]:checked + label svg {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}
.check > span {
  display: inline-flex;
  align-items: center;
}

.fake-checkbox {
  width: 30px;
  height: 30px;
  display: inline-block;
  border: 2px solid #ddd;
  margin-right: 12px;
  border-radius: 3px;
  position: relative;
}

label {
  display: inline-flex;
  align-items: center;
  border-radius: 3px;
  font-size: 20px;
  padding: 1em;
  margin: 8px 0px;
  border-radius: 6px;
  box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.06);
}
label svg {
  opacity: 0;
  width: 100%;
  height: 100%;
  position: absolute;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  transform: rotate(-30deg) scale(0.8);
}
</style>

</head>

<body  >
  <div class="container">
	<div class="check">
		<input type="checkbox" id="its-friday" />
		<label fo.........完整代码请登录后点击上方下载按钮下载查看

网友评论0