Skip to content
Advertisements

CSS Animation Radio Buttons

CSS Animation Radio Buttons

Github: https://github.com/Furkan-Gulsen/HTML-CSS-JAVASCRIPT/tree/master/Animation%20Button%202


HTML CODE

<!DOCTYPE html>

<html>
<head>
    <meta charset="utf-8" />
    <title>page</title>
    <link rel="stylesheet" type="text/css" href="1.page.css">
    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
</head>
<body>

    <h1>animation radio button</h1>
    <div id="radio_buttons">
        <input type="radio" name="sec" id="input1" />
        <label for="input1"></label>
        <input type="radio" name="sec" id="input2" />
        <label for="input2"></label>
        <input type="radio" name="sec" id="input3" />
        <label for="input3"></label>
        <input type="radio" name="sec" id="input4" />
        <label for="input4"></label>
        <input type="radio" name="sec" id="input5" />
        <label for="input5"></label>
        <span id="slider"></span>
    </div>


</body>
</html>

CSS CODE

body{
    margin:0;
    padding:0;
    box-sizing:border-box;
    background:#262626;
    padding-bottom:10%;
}

h1{
    text-align: center;
    margin: 20% 0 5%;
    font-family: 'AR DARLING';
    text-transform: uppercase;
    font-size: 50px;
    color: #e4e4e4;
}

#radio_buttons{
    position:relative;
    width:50%;
    margin:0 auto;
}

input[type="radio"]{
    position:absolute;
    right:1000%;
}

label {
    float: left;
    width: 15%;
    padding-bottom: 15%;
    margin: 0 2.5%;
    background: rgba(0,0,0,.3);
    border-radius:20%;
    cursor:pointer;
}

#slider {
    position: absolute;
    left: 0%;
    top: 0%;
    width: 10%;
    padding-bottom: 10%;
    margin: 2.5% 0 0 5%;
    background: #e4e4e4 ;
    transition: transform 1s;
    border-radius: 50%;
    animation: .3s forwards ease-in-out;
    transition: 0.2s left .05s ease-in-out;
}


#input1:checked ~ #slider {
    animation-name: input1;
    left: 0;
}

#input2:checked ~ #slider {
    animation-name: input2;
    left: 20%;
}

#input3:checked ~ #slider {
    animation-name: input3;
    left: 40%;
}

#input4:checked ~ #slider {
    animation-name: input4;
    left: 60%;
}

#input5:checked ~ #slider {
    animation-name: input5;
    left: 80%;
}
@keyframes input1 {
    30%, 70% {
        transform: scale(0.5);
    }
}


@keyframes input2 {
    30%, 70% {
        transform: scale(0.5);
    }
}
@keyframes input3 {
    30%, 70% {
        transform: scale(0.5);
    }
}
@keyframes input4 {
    30%, 70% {
        transform: scale(0.5);
    }
}
@keyframes input5 {
    30%, 70% {
        transform: scale(0.5);
    }
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: