Bulb ON - OFF animation using only HTML and CSS.(No JavaScript)

 Bulb ON - OFF Animation using HTML and CSS.


                                                                           

                                        Hey guy's another very good program for you all! This is a simple web program that will show BULB ON - OFF Animation using Only HTML and CSS code .No  JavaScript code is used . We have used two images , one is when Bulb is OFF and another when bulb is ON. As you press button that we have designed then you will find that bulb is glowing and if you repress that button again if bulb is ON then Bulb will  be OFF and vice versa. We have smartly used  OPACITY property of CSS. So see the below code and understand that how did we use opacity property in our code.




PROGRAM SOURCE CODE :-



1) HTML Coding Part :-



<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Bulb ON/OFF Aniamtion Creation</title>
    <link rel="stylesheet" href="Bulb_ON_OFF.css">
</head>
<body>
    <header>
        <marquee scrollamount="10">
            <h1>Bulb On - off Aniamtion</h1>  
        </marquee>
    </header>
    <div class="main">
        <input type="checkbox" id="i"/>
        <label for="i">
            <h1></h1>
        </label>
        <div class="image-container">
            <img src="bulb-off.png" alt="bulb is OFF" id="i1">
            <img src="bulb-on.png" alt="bulb is ON" id="i2">
        </div>
    </div>
</body>
</html>





2) CSS Coding Part :-


*{
    margin:0;
    padding0;
    box-sizingborder-box;
}
html{
    font-size62.5%;
}
:root{
    --b : #000;
    --w : #fff;
}
body{
    background-colorvar(--b);
    overflowhidden;
}
header{
    width100%;
    height0vh;
    padding-top1rem;
}
header marquee h1{
    colorvar(--w);
    font-size3rem;
    font-family:'Segoe UI';
    text-transformuppercase;
    letter-spacing.15rem;
}

.main{
    width100vw;
    height100vh;
    displayflex;
    justify-contentcenter;
    align-itemscenter;
    positionrelative;
}

.image-container{
    width40rem;
    height40rem;
    positionrelative;
}

img{
    positionabsolute;
    width100%;
    height100%;
    transformrotate(180deg);
}
label{
    positionabsolute;
    bottom7rem;
    padding1rem 2rem;
    cursorpointer;
    font-family:Verdana;
    font-weight600;
    letter-spacing.12rem;
    border-radius1rem;
    outlinenone;
    color:var(--b);
    background-color#ffd;
}
label h1::before{
    content'SWITCH ON';
}
input{
    displaynone;
}
#i2{
    opacity0;
}
#i:checked ~.image-container #i2{
    opacity1;
}
#i:checked ~ label h1::before{
    content'SWITCH OFF';
}





OUTPUT :- 






( NOTE : - While executing program you have to replace links of images , audio's  or video's in this program by your links. So take care of it ! )