Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
MarieCarolineLivaditis committed Mar 20, 2022
0 parents commit 2735e63
Show file tree
Hide file tree
Showing 4 changed files with 184 additions and 0 deletions.
35 changes: 35 additions & 0 deletions index.html
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>
47 changes: 47 additions & 0 deletions index.js
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)
68 changes: 68 additions & 0 deletions reset.css
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;
}
34 changes: 34 additions & 0 deletions style.css
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;
}

0 comments on commit 2735e63

Please sign in to comment.