<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Random Color Generator</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #333;
color: white;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
.container {
text-align: center;
padding: 40px;
background-color: #444;
border-radius: 10px;
box-shadow: 0 4px 30px rgba(0, 0, 0, 0.6);
}
h1 {
font-size: 2rem;
color: #ff6f61;
}
.color-box {
margin: 20px 0;
width: 200px;
height: 200px;
background-color: #fff;
border-radius: 10px;
transition: background-color 0.3s ease;
}
.btn {
padding: 15px 30px;
background-color: #ff6f61;
color: white;
border: none;
border-radius: 30px;
font-size: 1.2rem;
cursor: pointer;
transition: background-color 0.3s ease;
}
.btn:hover {
background-color: #ff3f2f;
}
</style>
</head>
<body>
<div class="container">
<h1>Random Color Generator</h1>
<div class="color-box" id="colorBox"></div>
<button class="btn" onclick="generateColor()">Generate Color</button>
<p id="a">
</p>
</div>
<script>
function generateColor() {
const randomColor = '#' + Math.floor(Math.random()*16777215).toString(16);
document.getElementById('colorBox').style.backgroundColor = randomColor;
document.getElementById("a").innerHTML = "Hex code: " + randomColor
}
</script>
</body>
</html>