Skip to content

Commit 583b4ab

Browse files
committed
Added Mini Project - Basic Background Generator
1 parent 0b85cdb commit 583b4ab

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed

Basic Background Generator/index.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Gradient Background</title>
5+
<link rel="stylesheet" type="text/css" href="style.css">
6+
</head>
7+
<body id = "gradient">
8+
<h1>Background Generator</h1>
9+
<input class = "color1" type="color" name="color1" value = "#ff0000">
10+
<input class = "color2" type="color" name="color2" value = "#ffff00">
11+
<h2>Current CSS Background</h2>
12+
<h3></h3>
13+
<script type="text/javascript" src = "script.js"></script>
14+
</body>
15+
</html>

Basic Background Generator/script.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
var css = document.querySelector("h3");
2+
var color1 = document.querySelector(".color1");
3+
var color2 = document.querySelector(".color2");
4+
var body = document.getElementById("gradient");
5+
6+
function setGradient() {
7+
body.style.background =
8+
"linear-gradient(to right, "
9+
+ color1.value
10+
+ ", "
11+
+ color2.value
12+
+")";
13+
14+
css.textContent = body.style.background + ";";
15+
}
16+
17+
color1.addEventListener("input", setGradient)
18+
19+
color2.addEventListener("input", setGradient)

Basic Background Generator/style.css

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
body {
2+
font: 'Raleway', sans-serif;
3+
color: rgba(0,0,0,.5);
4+
text-align: center;
5+
text-transform: uppercase;
6+
letter-spacing: .5em;
7+
top: 15%;
8+
background: linear-gradient(to right, red , yellow); /* Standard syntax */
9+
}
10+
11+
h1 {
12+
font: 600 3.5em 'Raleway', sans-serif;
13+
color: rgba(0,0,0,.5);
14+
text-align: center;
15+
text-transform: uppercase;
16+
letter-spacing: .5em;
17+
width: 100%;
18+
}
19+
20+
h3 {
21+
font: 900 1em 'Raleway', sans-serif;
22+
color: rgba(0,0,0,.5);
23+
text-align: center;
24+
text-transform: none;
25+
letter-spacing: 0.01em;
26+
27+
}

0 commit comments

Comments
 (0)