Skip to content
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
43 changes: 43 additions & 0 deletions projects/Random_Color_generator/css/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
* {
margin: 0;
padding: 0;
}

html {
font-size: 16px;
}

.mainDiv {
min-height: 100vh;
width: 100vw;
display: flex;
justify-content: center;
align-items: center;
transition: background-color 0.4s;
}

.randomBtn {
background-color: skyblue;
border: 0;
padding: 1rem 1.5rem 1rem 1.5rem;
font-size: 1.2rem;
border-radius: 1rem;
cursor: pointer;
transition: font-size 0.5s;
}

.randomBtn:hover {
font-size: 1.24rem;
background-color: rgb(137, 204, 231);
}

@media screen and (max-width: 380px) {
html {
font-size: 10px;
}

.randomBtn {
margin-left: 1rem;
margin-right: 1rem;
}
}
17 changes: 17 additions & 0 deletions projects/Random_Color_generator/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<link rel="stylesheet" href="css/styles.css" />
</head>
<body>
<div class="mainDiv">
<button class="randomBtn" onclick="generateColor()">
Click to generate a random color
</button>
</div>
<script src="index.js"></script>
</body>
</html>
10 changes: 10 additions & 0 deletions projects/Random_Color_generator/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function generateColor() {
let x = Math.random() * 255;
let y = Math.random() * 255;
let z = Math.random() * 255;
let o = Math.random();

document.getElementsByClassName(
"mainDiv"
)[0].style.backgroundColor = `rgba(${x}, ${y}, ${z}, ${o})`;
}