css实现多种radio切换效果

代码语言:html

所属分类:表单美化

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


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">

<title>C Toggle buttons / On-Off switches</title>
<style>
    body
{
    margin: 0px;
    background-color: #f8f8f8;
}

h1
{
    font-family: Segoe UI;
    text-align: center;
    line-height: 42px;
    padding-bottom: 23px;
    margin: 10px 0px;
    border-bottom: 1px solid #dadada;
}

#hash-symbol
{
    color: #484848;
    font-size: 42px;
    position: relative;
    top: 4px;
}

#app-name
{
    color: #f19000;
}

section
{
    width: 250px;
    margin: 100px auto;
    padding: 60px;
    background-color: #fff;
    box-shadow: 0px 5px 35px #d7d7d7;
    border-radius: 35px;
}

.toggle-btn
{
    position: relative;
    width: 145px;
    height: 74px;
    margin: 0 auto;
    border-radius: 40px;
}

input[type="checkbox"]
{
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0px;
    left: 0px;
    right: 0px;
    bottom: 0px;
    margin: 0px;
    cursor: pointer;
    opacity: 0;
    z-index: 2;
}

/* First toggle btn */

#_1st-toggle-btn span
{
    position: absolute;
    top: 0px;
    right: 0px;
    bottom: 0px;
    left: 0px;
    overflow: hidden;
    opacity: 1;
    background-color: #fff;
    box-shadow: 0px 2px 25px #d9d9d9;
    border-radius: 40px;
    transition: 0.2s ease background-color, 0.2s ease opacity;
}

#_1st-toggle-btn span:before,#_1st-toggle-btn span:after
{
    content: '';
    position: absolute;
    top: 8px;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    transition: 0.5s ease transform, 0.2s ease background-color;
}

#_1st-toggle-btn span:before
{
    background-color: #fff;
    transform: translate(-58px,0px);
    z-index: 1;
}

#_1st-toggle-btn span:after
{
    background-color: #000;
    transform: translate(8px,0px);
    z-index: 0;
}

#_1st-toggle-btn input[type="checkbox"]:checked + span
{
    background-color: #000;
}

#_1st-toggle-btn input[type="checkbox"]:active + span
{
    opacity: 0.5;
}

#_1st-toggle-btn input[type="checkbox"]:checked + span:before
{
    background-color: #000;
    transform: translate(56px,-19px);
}

#_1st-toggle-btn input[type="checkbox"]:checked + span:after
{
    background-color: #fff;
    transform: translate(79px,0px);
}

/* First toggle btn completed */

/* Second toggle btn */

#_2nd-toggle-btn
{
    margin: 60px auto 76px auto;
}

#_2nd-toggle-btn span
{
    position: absolute;
    top: 0px;
    right: 0px;
    bottom: 0px;
    left: 0px;
    border: 8px solid #b3b3b3;
    border-color: #b3b3b3;
    overflow: hidden;
    background-color: #fff;
    border-radius: 40px;
    transition: 0.8s ease border-color;
}

#_2nd-toggle-btn span:before
{
    content: '';
    position: absolute;
    top: -8px;
    width: .........完整代码请登录后点击上方下载按钮下载查看

网友评论0