Skip to content

Commit 8c6820f

Browse files
authored
Merge pull request #915 from 05hiteshbansal/random_linear_Gradient
Added Linear-Gradient as a micro Project
2 parents f84e5dc + 561ff73 commit 8c6820f

File tree

5 files changed

+112
-0
lines changed

5 files changed

+112
-0
lines changed
12.4 KB
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
*{
2+
padding: 0%;
3+
margin: 0%;
4+
5+
}
6+
7+
.container{
8+
display: flex;
9+
width: 100vw;
10+
height: 100vh;
11+
justify-content: center;
12+
align-items: center;
13+
flex-direction: column;
14+
}
15+
.text{
16+
width: 50%;
17+
text-align: center;
18+
display: block;
19+
font-size:1.5vmax;
20+
font-family: Cambria, Cochin, Georgia, Times, 'Times New Roman', serif;
21+
}
22+
.box{
23+
cursor: cell;
24+
margin-top: 10px;
25+
display: flex;
26+
flex-direction: row;
27+
background-color: rgb(54, 50, 50);
28+
align-items: center;
29+
justify-items: center;
30+
}
31+
.box>img{
32+
height:2vmax;
33+
width: 2vmax;
34+
}
35+
.box>button{
36+
background-color: initial;
37+
border: 0cap;
38+
color: white;
39+
font-size: 1.5vmax;
40+
font-size: medium;
41+
font-family: Cambria, Cochin, Georgia, Times, 'Times New Roman', serif;
42+
padding: 1vmax 0.5vmax ;
43+
cursor: cell;
44+
}
45+
46+
.box:hover{
47+
background-color:rgb(30, 28, 28);
48+
}
49+
50+
.inner{
51+
width: 60%;
52+
padding: 2vmax 0.5vmax;
53+
background-color:color-mix(in hsl increasing hue, rgb(63, 62, 62) 20%, white 30%);
54+
display: flex;
55+
align-items: center;
56+
justify-items: center;
57+
flex-direction: column;
58+
border-radius: 10px;
59+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<link
7+
rel="stylesheet"
8+
href="./home.css"
9+
crossorigin="anonymous"
10+
/>
11+
<title>Linear-Gradient</title>
12+
</head>
13+
<body>
14+
<div class="container">
15+
<div class="inner">
16+
<div class="text">Click to Generate Gradient</div>
17+
<div class="box">
18+
<button class="btn">Change Colour</button>
19+
<img src="./copy.png" alt="copy">
20+
</div>
21+
</div>
22+
</div>
23+
<script src="./home.js"></script>
24+
</body>
25+
</html>
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const button =document.getElementsByClassName('btn')[0]
2+
const text =document.getElementsByClassName('text')[0]
3+
const container = document.getElementsByClassName('container')[0]
4+
5+
async function displayDate(){
6+
console.log(1)
7+
let colours =[];
8+
let m = Math.floor(Math.random()*6)+2;
9+
for(let i =0; i<m ; i++){
10+
let colour=`rgb(${Math.floor(Math.random() * 256)}, ${Math.floor(Math.random() * 256)}, ${Math.floor(Math.random() * 256)})`
11+
colours.push(colour)
12+
}
13+
console.log(colours)
14+
let value =container.style.background =`linear-gradient(${Math.floor(Math.random() * 360)}deg, ${colours.join(',')})`;
15+
text.innerHTML =value
16+
await navigator.clipboard.writeText(value).then(()=>{
17+
alert("Gradient added in ClipBoard")
18+
});
19+
20+
}
21+
22+
console.log(2);
23+
button.addEventListener("click", displayDate);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## Linear-colour-Gradient
2+
3+
### Javascript Linear-colour-Gradient
4+
5+
This project is a javascript based Product. It allows you to click a cell and make a random Linear Gradient at random degree with random colours . Also number of colours are also not specific so a user can generate linear-Gradient with any number of colours

0 commit comments

Comments
 (0)