Hex-Code Color Generator

Ritik Tiwari
1 min readApr 17, 2023

--

Here is the code to make the Hex-Code Color Generator with HTML, CSS & JS, you can use this stuff in your projects and showcase it in the portfolio.

HTML CODE

<!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>Hex Color Generator</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="container">
<input type="text" id="clr" value="#FFFFFF">
</div>
<script src="main.js"></script>
</body>
</html>

CSS CODE

*{
padding: 0;
margin: 0;
box-sizing: border-box;
outline: none;
}
body{
width: 100vw;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}
#container{
width: 30%;
height: 30%;
display: flex;
justify-content: center;
align-items: center;
box-shadow: 0px 20px 30px rgba(75, 75, 75, .2);
border-radius: 15px;
}

JAVASCRIPT CODE

let clr = document.getElementById('clr');
clr.addEventListener('input', function(){
document.getElementById('container').style.background = clr.value;
});

VIDEO TUTORIAL

Meet you in next story, signing off.

theritiktiwari 💙

--

--