-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2735e63
Showing
4 changed files
with
184 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<!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>Background generator</title> | ||
|
||
<link href="https://fonts.googleapis.com/css?family=Asap:400,700&display=swap" rel="stylesheet"> | ||
|
||
<link rel="stylesheet" href="reset.css"> | ||
<link rel="stylesheet" href="style.css"> | ||
</head> | ||
|
||
<body id="gradient"> | ||
|
||
<h1 id="title">Background generator</h1> | ||
<h2 id="subtitle">Linear-gradient background</h2> | ||
<div> | ||
<input class="color1" type="color" name="color1" value="#FFFFFF"> | ||
<input id="color2" type="color" name="color2" value="#000000"> | ||
</div> | ||
|
||
<h3 id="h3"></h3> | ||
|
||
<button id="random">Random</button> | ||
<button id="auto">Auto</button> | ||
<button id="stop">Stop</button> | ||
|
||
<script src="index.js"></script> | ||
|
||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
let color1 = document.querySelector('.color1'); | ||
let color2 = document.getElementById('color2'); | ||
let body = document.getElementById('gradient'); | ||
let css = document.getElementById('h3'); | ||
let randomColor = document.getElementById('random'); | ||
let autoColor = document.getElementById('auto'); | ||
let stopAuto = document.getElementById('stop') | ||
|
||
|
||
function setGradient() { | ||
body.style.background = `linear-gradient(to left, ${color1.value}, ${color2.value})`; | ||
css.textContent = `linear-gradient(to left, ${color1.value}, ${color2.value})`; | ||
}; | ||
|
||
function random() { | ||
const randomColor = `#`+ (Math.random() * 0xFFFFFF << 0).toString(16); | ||
return randomColor | ||
}; | ||
|
||
function randomGradient() { | ||
color1.value = random(); | ||
color2.value = random(); | ||
setGradient(); | ||
}; | ||
|
||
let interval; | ||
|
||
function auto() { | ||
interval = setInterval(randomGradient, 2000); | ||
} | ||
|
||
|
||
function stop() { | ||
clearInterval(interval); | ||
|
||
interval = null; | ||
}; | ||
|
||
setGradient(); | ||
|
||
color1.addEventListener('input', setGradient); | ||
color2.addEventListener('input', setGradient); | ||
randomColor.addEventListener('click', randomGradient); | ||
|
||
autoColor.addEventListener('click', auto); | ||
|
||
stopAuto.addEventListener('click', stop) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* http://meyerweb.com/eric/tools/css/reset/ | ||
v2.0 | 20110126 | ||
License: none (public domain) | ||
*/ | ||
|
||
html, body, div, span, applet, object, iframe, | ||
h1, h2, h3, h4, h5, h6, p, blockquote, pre, | ||
a, abbr, acronym, address, big, cite, code, | ||
del, dfn, em, img, ins, kbd, q, s, samp, | ||
small, strike, strong, sub, sup, tt, var, | ||
b, u, i, center, | ||
dl, dt, dd, ol, ul, li, | ||
fieldset, form, label, legend, | ||
table, caption, tbody, tfoot, thead, tr, th, td, | ||
article, aside, canvas, details, embed, | ||
figure, figcaption, footer, header, hgroup, | ||
menu, nav, output, ruby, section, summary, | ||
time, mark, audio, video { | ||
margin: 0; | ||
padding: 0; | ||
border: 0; | ||
font-size: 100%; | ||
font: inherit; | ||
vertical-align: baseline; | ||
} | ||
/* HTML5 display-role reset for older browsers */ | ||
article, aside, details, figcaption, figure, | ||
footer, header, hgroup, menu, nav, section { | ||
display: block; | ||
} | ||
body { | ||
line-height: 1; | ||
} | ||
ol, ul { | ||
list-style: none; | ||
} | ||
blockquote, q { | ||
quotes: none; | ||
} | ||
blockquote:before, blockquote:after, | ||
q:before, q:after { | ||
content: ''; | ||
content: none; | ||
} | ||
table { | ||
border-collapse: collapse; | ||
border-spacing: 0; | ||
} | ||
|
||
/* Reset perso */ | ||
a, del, ins { | ||
text-decoration: none; | ||
} | ||
a { | ||
color: inherit; | ||
} | ||
label, button { | ||
cursor: pointer; | ||
} | ||
html { | ||
box-sizing: border-box; | ||
} | ||
*, *:before, *:after { | ||
box-sizing: inherit; | ||
} | ||
input, button { | ||
outline: 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
body { | ||
text-align: center; | ||
font-family: 'Asap', sans-serif; | ||
background: linear-gradient(to left, #FFF, #000); | ||
} | ||
|
||
h1 { | ||
font-size: 6rem; | ||
font-weight: bold; | ||
padding: 2.5rem; | ||
} | ||
|
||
h2 { | ||
font-size: 4rem; | ||
font-weight: 500; | ||
padding: 2.5rem; | ||
} | ||
|
||
h3 { | ||
font-size: 2rem; | ||
|
||
} | ||
|
||
button { | ||
border-radius: 15px; | ||
background-color: #FFF; | ||
font-size: 1.7rem; | ||
padding: 0.7rem; | ||
margin: 1rem; | ||
} | ||
|
||
input{ | ||
margin: 1rem; | ||
} |