温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

CSS3代码如何实现复选框动画特效

发布时间:2023-01-05 10:27:37 阅读:130 作者:iii 栏目:开发技术
前端开发者测试专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

本篇内容主要讲解“CSS3代码如何实现复选框动画特效”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“CSS3代码如何实现复选框动画特效”吧!

实例代码

<!DOCTYPE html>
<html>
<head>
   <meta charset="UTF-8">
   <title>CheckBox</title>
   <style>
       .checkbox {
           width900px;
           padding3% 0%;
           margin50px auto;
           background-color: cornsilk;
           text-align: center;
       }</p> <p>        .checkbox label {
           display: inline-block;
           width64px;
           height32px;
           margin-right10px;
           background-color#ffffff;
           border1px solid #eeeeee;
           border-radius17px;
           cursor: pointer;
           position: relative;
           transition: background-color .2s ease-in;
       }</p> <p>        .checkbox label:after {
           content"";
           width30px;
           height30px;
           border-radius50%;
           background-color#eeeeee;
           position: absolute;
           left1px;
           top1px;
           transformtranslateX(0px);
           transition: transform .2s ease-in;
       }</p> <p>        .checkbox [type="checkbox"]:checked + label {
           background-color: khaki;
           transition: background-color .2s ease-in;
       }</p> <p>        .checkbox [type="checkbox"]:checked +label:after{
           transformtranslateX(30px);
           transition: transform .2s ease-in;
       }</p> <p>        .checkbox [type="checkbox"]{
           display: none;
       }
   </style>
</head>
<body>
<div>
   <input type="checkbox" id="checkbox-1">
   <label for="checkbox-1"></label></p> <p>    <input type="checkbox" id="checkbox-2">
   <label for="checkbox-2"></label></p> <p>    <input type="checkbox" id="checkbox-3">
   <label for="checkbox-3"></label>
</div></p> <p></body>
</html>

再来看我们的第二个特效图

CSS3代码如何实现复选框动画特效

代码如下:

<!DOCTYPE html>
<html>
<head>
   <meta charset="UTF-8">
   <title>Title</title>
   <style>
       .checkbox {
           width900px;
           padding3% 0px;
           margin50px auto;
           background-color: cornsilk;
           text-align: center;
       }</p> <p>        .checkbox label {
           position: relative;
           display: inline-block;
           width30px;
           height30px;
           margin-right10px;
           overflow: hidden;
           border1px solid #eeeeee;
           background-color#ffffff;
           cursor: pointer;
       }</p> <p>        .checkbox label:after {
           content"&radic;";
           position: absolute;
           width28px;
           height28px;
           line-height26px;
           background-color: khaki;
           color#ffffff;
           left1px;
           top1px;
           text-align: center;
           transformtranslateY(-30px);
           transition: transform .2s ease-out;
           border-radius4px;
       }</p> <p>        .checkbox [type="checkbox"]:checked + label:after {
           transformtranslateY(0px);
           transition: transform .2s ease-in;
       }
       .checkbox [type="checkbox"]{
           display: none;
       }
   </style>
</head>
<body>
<div>
   <input type="checkbox" id="checkbox-1" checked="checked">
   <label for="checkbox-1"></label></p> <p>    <input type="checkbox" id="checkbox-2">
   <label for="checkbox-2"></label></p> <p>    <input type="checkbox" id="checkbox-3">
   <label for="checkbox-3"></label>
</div></p> <p></body>
</html>

css的选择器有哪些

css的选择器可以分为三大类,即id选择器、class选择器、标签选择器。它们之间可以有多种组合,有后代选择器、子选择器、伪类选择器、通用选择器、群组选择器等等

到此,相信大家对“CSS3代码如何实现复选框动画特效”有了更深的了解,不妨来实际操作一番吧!这里是亿速云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!

亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI

开发者交流群×