Add files via upload
This commit is contained in:
parent
d98d36c965
commit
30ce6b6be0
19
100_projects/54-traffic-lights/inedx.html
Normal file
19
100_projects/54-traffic-lights/inedx.html
Normal file
@ -0,0 +1,19 @@
|
||||
<!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>Document</title>
|
||||
<link rel="stylesheet" href="style.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="circle red" color="red"></div>
|
||||
<div class="circle" color="yellow"></div>
|
||||
<div class="circle" color="green"></div>
|
||||
</div>
|
||||
|
||||
<script src="main.js"></script>
|
||||
</body>
|
||||
</html>
|
18
100_projects/54-traffic-lights/main.js
Normal file
18
100_projects/54-traffic-lights/main.js
Normal file
@ -0,0 +1,18 @@
|
||||
const circles = document.querySelectorAll('.circle')
|
||||
let activeLight = 0;
|
||||
|
||||
setInterval(() => {
|
||||
changeLight();
|
||||
}, 1000);
|
||||
|
||||
function changeLight() {
|
||||
circles[activeLight].className = 'circle';
|
||||
activeLight++;
|
||||
|
||||
if(activeLight > 2) {
|
||||
activeLight = 0;
|
||||
}
|
||||
const currentLight = circles[activeLight]
|
||||
|
||||
currentLight.classList.add(currentLight.getAttribute('color'));
|
||||
}
|
65
100_projects/54-traffic-lights/style.css
Normal file
65
100_projects/54-traffic-lights/style.css
Normal file
@ -0,0 +1,65 @@
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
body {
|
||||
background-color: #4682B4;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 100vh;
|
||||
margin: 0;
|
||||
}
|
||||
.container {
|
||||
position: relative;
|
||||
background-color: rgba(0, 0, 0, .5);
|
||||
border-radius: 10px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: space-around;
|
||||
padding: 15px 0;
|
||||
height: 200px;
|
||||
width: 70px;
|
||||
border: 3px solid #FFA500;
|
||||
}
|
||||
.container::before{
|
||||
content: '';
|
||||
position: absolute;
|
||||
left:50%;
|
||||
transform: translateX(-50%);
|
||||
bottom: -250px;
|
||||
width: 30px;
|
||||
border-radius: 10px;
|
||||
height: 250px;
|
||||
background: #FFA500;
|
||||
z-index: -1;
|
||||
}
|
||||
.circle {
|
||||
background-color: rgba(0, 0, 0, 0.3);
|
||||
border-radius: 100%;
|
||||
position: relative;
|
||||
height: 40px;
|
||||
width: 40px;
|
||||
}
|
||||
.circle::after {
|
||||
border-right: 4px solid rgba(255, 255, 255, 0.6);
|
||||
border-radius: 100%;
|
||||
content: ' ';
|
||||
position: absolute;
|
||||
top: 5px;
|
||||
left: 0px;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
}
|
||||
.circle.red {
|
||||
background-color: #c0392b;
|
||||
box-shadow: 0 0 20px 5px #c0392b;
|
||||
}
|
||||
.circle.yellow {
|
||||
background-color: #f1c40f;
|
||||
box-shadow: 0 0 20px 5px #f1c40f;
|
||||
}
|
||||
.circle.green {
|
||||
background-color: #2ecc71;
|
||||
box-shadow: 0 0 20px 5px #2ecc71;
|
||||
}
|
Loading…
Reference in New Issue
Block a user