Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random Color Generator #79

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Js-RandomColourGenerator/favicon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions Js-RandomColourGenerator/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!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>Random Color Generator</title>
<link rel="stylesheet" href="./style.css">
<link rel="icon" type="image/png" sizes="32x32" href="favicon-32x32.png">
</head>

<body>
<div class="container">
<p id="color">...</p>
<button onclick="getColor()">Change</button>
</div>
<script src="script.js"></script>
</body>

</html>
11 changes: 11 additions & 0 deletions Js-RandomColourGenerator/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
let letters = "0123456789ABCDEF";
const body = document.querySelector("body");
const colorelement = document.querySelector("#color");
function getColor() {
let color = "#";
for (let i = 0; i < 6; i++) {
color += letters[Math.floor(Math.random() * letters.length)];
}
body.style.backgroundColor = color;
colorelement.innerHTML = color;
}
39 changes: 39 additions & 0 deletions Js-RandomColourGenerator/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: sans-serif;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background: #2c3036;
transition: 0.1s;
}
#color {
margin-bottom: 20px;
font-size: 24px;
padding: 8px 16px;
text-align: center;
color: #fff;
background: #000;
}
button {
padding: 20px 48px;
border: none;
outline: none;
font-size: 20px;
font-weight: 700;
letter-spacing: 2px;
background: #2a4636;
color: #fff;
border: 2px solid #01d401;
transition: 100ms ease-in-out;
}
button:hover{
outline:none;
color: white;
box-shadow: 0 0 50px 50px #01d401 inset, 0 0 10px #01d401;
}