Menu

1 / 2

🚦 Traffic Lights Project!

DEV Community: cssΒ·AyeshaΒ·9 days ago
#vr1ewxiH
#devtocss#devto#dev#opacity#light
Reading 0:00
15s threshold

I recently built a simple Traffic Lights project using HTML, CSS, and JavaScript.

This mini project helped me practise JavaScript basics, DOM manipulation, and working with interactive elements while bringing a familiar real-world concept to life.

Small projects, consistent practice, and learning something new every day!

Code

<!DOCTYPE HTML> <html> <head> <title> Traffic Light </title> <style> body { background-color : #111 ; display : flex ; align-items : center ; justify-content : center ; height : 100vh ; margin : 0 ; }

.traffic-light { background-color : #222 ; padding : 20px ; border-radius : 15px ; }

.red-light , .yellow-light , .green-light { width : 80px ; height : 80px ; border-radius : 50% ; margin : 15px ; opacity : 0.2 ; }

.red-light { background-color : red ; animation : redlight 2s infinite ; }

.yellow-light { background-color : yellow ; animation : yellowlight 2s infinite ; }

.green-light { background-color : greenyellow ; animation : greenlight 2s infinite ; }

@keyframes redlight {…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.