Back
A delightful journey into creating a responsive button that morphs with a touch of modern artistry, offering a tactile visual experience.
<div class="sculpture-container">
<button class="sculpture-button">
<span class="sculpture-text">Press Me</span>
</button>
</div>
document.querySelector('.sculpture-button').addEventListener('mouseover', function() {
this.classList.add('hovered');
});
document.querySelector('.sculpture-button').addEventListener('mouseout', function() {
this.classList.remove('hovered');
});
.sculpture-container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
The .sculpture-button class is where most of our styles are applied:
.sculpture-button {
background: linear-gradient(145deg, #ffffff, #e6e6e6);
border-radius: 20px;
border: none;
padding: 20px 40px;
box-shadow: 5px 5px 10px #cccccc,
-5px -5px 10px #ffffff;
transition: transform 0.3s ease;
cursor: pointer;
}
The .sculpture-text class styles the text inside the button:
.sculpture-text {
font-family: 'Arial', sans-serif;
font-weight: bold;
font-size: 18px;
color: #333333;
transition: color 0.3s ease;
}
And there you have it! With these few steps, you've created a visually dynamic button that's both fun and functional.<div class="sculpture-container">
<button class="sculpture-button">
<span class="sculpture-text">Press Me</span>
</button>
</div>
<script>
document.querySelector('.sculpture-button').addEventListener('mouseover', function() {
this.classList.add('hovered');
});
document.querySelector('.sculpture-button').addEventListener('mouseout', function() {
this.classList.remove('hovered');
});
</script>
<style>
.sculpture-container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.sculpture-button {
background: linear-gradient(145deg, #ffffff, #e6e6e6);
border-radius: 20px;
border: none;
padding: 20px 40px;
box-shadow: 5px 5px 10px #cccccc,
-5px -5px 10px #ffffff;
transition: transform 0.3s ease;
cursor: pointer;
}
.sculpture-button.hovered {
transform: scale(1.1) rotate(-3deg);
}
.sculpture-text {
font-family: 'Arial', sans-serif;
font-weight: bold;
font-size: 18px;
color: #333333;
transition: color 0.3s ease;
}
.sculpture-button.hovered .sculpture-text {
color: #007bff;
}
</style>
Thank you for reading this article.
Comments