Create a Light Blub using ChatGPT

 


<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Light Bulb</title>
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap">
  <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
  <style>
    body {
      display: flex;
      justify-content: center;
      align-items: center;
      height: 100vh;
      margin: 0;
      background-color: #121212; /* dark background */
    }
    #container {
      display: flex;
      flex-direction: column;
      align-items: center;
    }
    #lightbulb {
      font-size: 200px;
      color: #ccc;
      transition: color 0.5s;
    }
    #switch {
      margin-top: 20px;
    }
  </style>
</head>
<body>
  <div id="container">
    <i class="material-icons lightbulb-off" id="lightbulb">lightbulb_outline</i>
    <div id="switch" class="switch">
      <label>
        Off
        <input type="checkbox" id="toggle">
        <span class="lever"></span>
        On
      </label>
    </div>
  </div>

  <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
  <script>
    const lightbulb = document.getElementById('lightbulb');
    const toggleSwitch = document.getElementById('toggle');

    toggleSwitch.addEventListener('change', function() {
      if (toggleSwitch.checked) {
        lightbulb.style.color = '#ffeb3b'; // yellow when on
        lightbulb.classList.remove('lightbulb-off');
        lightbulb.classList.add('lightbulb-on');
        lightbulb.textContent = 'lightbulb'; // change icon to filled bulb
      } else {
        lightbulb.style.color = '#ccc'; // gray when off
        lightbulb.classList.remove('lightbulb-on');
        lightbulb.classList.add('lightbulb-off');
        lightbulb.textContent = 'lightbulb_outline'; // change icon back to outline bulb
      }
    });
  </script>
</body>
</html>

Comments

Popular posts from this blog

Exploring Various Types of Buttons in Android Studio: A Beginner's Guide

Kotlin Chat Application Development Explained