Skip to content

Commit bd4b929

Browse files
authored
project file
1 parent ab2fa9f commit bd4b929

File tree

3 files changed

+113
-0
lines changed

3 files changed

+113
-0
lines changed
Loading

index.html

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
8+
<title>JS-P3</title>
9+
<link rel="stylesheet" href="style.css">
10+
</head>
11+
12+
<body>
13+
14+
<h2>Update CSS variable with JS</h2>
15+
16+
<div class="controls">
17+
18+
<label for="spacing">Spacing:</label>
19+
20+
<input type="range" id="spacing" min="10" max="200" value="10" name="spacing" data-sizing="px">
21+
22+
<label for="blur">Blur:</label>
23+
24+
<input type="range" id="blur" name="blur" min="0" max="25" value="10" data-sizing="px">
25+
26+
<label for="base">Base Color</label>
27+
28+
<input type="color" name="base" id="base" value="#ffc600">
29+
30+
<label for="height"> Height </label>
31+
32+
<input type="range" name="height" id="height" min="10" max="100" data-sizing="vh" value="10">
33+
34+
<label for="rotate"> Rotate </label>
35+
36+
<input type="range" name="rotate" id="rotate" min="0" max="360" data-sizing="deg" value="0">
37+
38+
<label for="radius"> Radius </label>
39+
40+
<input type="range" name="radius" id="radius" min="0" max="100" data-sizing="px" value="0" >
41+
42+
</div>
43+
44+
<img src="82528602_845598082535414_6936156667733234811_n.jpg" alt="">
45+
46+
</body>
47+
<script>
48+
49+
var inputs = document.querySelectorAll(".controls input ");
50+
51+
function handler(){
52+
const suffix =this.dataset.sizing || "";
53+
document.documentElement.style.setProperty(
54+
`--${this.name}`,
55+
this.value+suffix
56+
);
57+
}
58+
59+
inputs.forEach(input=>input.addEventListener("change",handler));
60+
inputs.forEach(input=>input.addEventListener("mousemove",handler));
61+
62+
</script>
63+
64+
</html>

style.css

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
*{
2+
margin: 0;
3+
padding: 0;
4+
list-style: none;
5+
text-decoration: none;
6+
scroll-behavior: smooth;
7+
color: inherit;
8+
outline: none;
9+
}
10+
11+
body{
12+
text-align: center;
13+
background: #193549;
14+
color: white;
15+
font-family: Arial, Helvetica, sans-serif;
16+
font-weight: 100;
17+
font-size: 40px;
18+
}
19+
20+
:root{
21+
--base:#ffc600;
22+
--spacing:10px;
23+
--blur:10px;
24+
--height:10vh;
25+
--rotate:0deg;
26+
--radius:0px;
27+
}
28+
29+
img{
30+
padding: var(--spacing);
31+
background: var(--base);
32+
filter: blur(var(--blur));
33+
height: var(--height);
34+
transform: rotate(var(--rotate));
35+
border-radius: var(--radius);
36+
}
37+
38+
h2{
39+
color: var(--base);
40+
}
41+
42+
.controls{
43+
margin-bottom: 50px;
44+
margin-top: 20px;
45+
}
46+
47+
input{
48+
width: 100px;
49+
}

0 commit comments

Comments
 (0)