Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
mdashraful305 committed Apr 30, 2023
0 parents commit b77cba6
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 0 deletions.
50 changes: 50 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<title>Gradient Generator</title>
</head>

<body>
<div class="container my-5">
<div class="row">
<div class="col-md-6">
<h1 class="mb-4">Gradient Generator</h1>
<form>
<div class="form-group">
<label for="color1">Color 1:</label>
<div class="input-group">
<input type="color" id="color1" value="#2980B9" class="form-control form-control-lg">
</div>
<span class="input-group-text" id="ct1">#2980B9</span>
</div>
<div class="form-group">
<label for="color2">Color 2:</label>
<div class="input-group">
<input type="color" id="color2" value="#6DD5FA" class="form-control form-control-lg">
</div>
<span class="input-group-text" id="ct2">#6DD5FA</span>
</div>
<button type="submit" class="btn btn-primary btn-lg">Generate Gradient</button>
</form>
</div>
<div class="col-md-6">
<div class="gradient-container">
<div class="gradient"></div>
</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script>
<script src="script.js"></script>
</body>


</html>
14 changes: 14 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const form = document.querySelector('form');
const gradientContainer = document.querySelector('.gradient-container');
const gradient = document.querySelector('.gradient');

form.addEventListener('submit', (e) => {
e.preventDefault();

const color1 = document.querySelector('#color1').value;
const color2 = document.querySelector('#color2').value;

gradient.style.background = `linear-gradient(to right, ${color1}, ${color2})`;
$('#ct1').text(color1);
$('#ct2').text(color2);
});
24 changes: 24 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
body {
background-color: #f9f9f9;
}

.gradient-container {
height: 400px;
border-radius: 10px;
overflow: hidden;
}

.gradient {
width: 100%;
height: 100%;
background: linear-gradient(to right, #2980B9, #6DD5FA);
}

.input-group-text {
background-color: #fff;
border-color: #ced4da;
color: #495057;
width: 250px;
margin:5px 0;
}

0 comments on commit b77cba6

Please sign in to comment.