Off On Light Effect in HTML and CSS | Few lines of source code

Hello friends how are you , Today in this post "Off On Light Effect in HTML and CSS" i am going to teach you how you can create an OFF and ON light effect in  HTML using very simple lines of HTML and CSS code. If you wan to create something interesting using simple HTML and CSS then this post is for you. 

If you want to understand this through video then watch this video i have explained it step by step live

Now i am going to explain step by step.

Step 1:Create a Folder: Just  create a folder with any name and in any drive in your system, In my case my folder name is myhtml.

Step 2:Create an HTML file: Now open notepad and type the below code or you can copy this code for your personal use

<html>
    <head>
        <title>Light</title>
        <style>
            body{
                background-color: black;
            }
            .container
            {
               position: absolute;
               top: 50%;
               left: 50%;
               transform: translate(-50%,-50%);
               width: 500px;
               height: 500px;
               background-image: url('off.png');
               background-repeat: no-repeat;
               background-position: center center;
               transition: 1.5s;

            }
            .container:hover
            {
                transition: 1.5s;
                background-image: url('on.png');
                cursor: pointer;
                box-shadow: 1px 1px 50px cyan;
            }
        </style>
    </head>
    <body>
        <div class="container">

        </div>
    </body>
</html>

Now save this file with name light.html inside the created folder [myhtml]. Note:Don't forget to type .html after the file name because .html is the extension for HTML file.

Step 3:Download and store images: First click here to download images. When you will download it then you will get both images for off and on in a single image so first crop the images one by one then store these images into the folder myhtml.


After doing these your created folder will look like below.

Off On Light Effect in HTML and CSS


Step 4:Run HTML file: Now its time to run HTML file so right click on light html file and then select open with and then select chrome browser or you can select any browser for output. 

Off On Light Effect in HTML and CSS

You will get output screen like below screenshot.

Off On Light Effect in HTML and CSS

Now when you will move mouse on this bulb you will notice some lighting effect like below screenshot. For better experience and live result see the above video.

Off On Light Effect in HTML and CSS



I hope now you can  create "Off On Light Effect in HTML and CSS". If you have any doubt regarding this post  or you want something more in this post then let me know by comment below i will work on it definitely.
 

Request:-If you found this post helpful then let me know by your comment and share it with your friend. 
 
If you want to ask a question or want to suggest then type your question or suggestion in comment box so that we could do something new for you all. 

If you have not subscribed my website then please subscribe my website. Try to learn something new and teach something new to other. 

If you like my post then share it with your friends. Thanks😊Happy Coding.



Post a Comment

0 Comments