Light Bulb On/Off Using HTML /CSS

OUTPUT

<!DOCTYPE html>

<html lang="en">

  <head>

    <meta charset="UTF-8" />

    <meta name="viewport" content="width=device-width, initial-scale=1.0" />

    <title>Light Bulb On/off (rsportflio)</title>

    <style>

      body {

        background: #111;

        display: flex;

        justify-content: center;

        align-items: center;

        height: 100vh;

      }

      #switch {

        display: none;

      }

      .bulb {

        width: 150px;

        height: 150px;

        background-color: #333;

        border-radius: 50%;

        position: relative;

        box-shadow: inset 0 0 20px #000;

        transition: 0.3s;

        cursor: pointer;

      }

      .bulb::after {

        content: "";

        width: 40px;

        height: 25px;

        background-color: #555;

        position: absolute;

        bottom: -25px;

        left: 50%;

        transform: translateX(-50%);

        border-radius: 0 0 5px 5px;

      }

      #switch:checked + .bulb {

        background-color: #fff;

        box-shadow: 0 0 40px #fff, 0 0 80px red;

      }

    </style>

  </head>

  <body>

    <label>

      <input type="checkbox" id="switch" />

      <div class="bulb"></div>

    </label>

  </body>

</html>

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top