undefined / index.html
Builtgrowth's picture
the boxes need to rotate at an angle when they hover, the image should also blur so the text is easily readable
5a6d921 verified
Raw History Blame Contribute Delete
7.33 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>BentoMotion Boxes</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://unpkg.com/feather-icons"></script>
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js"></script>
<style>
.bento-box {
transition: all 0.5s cubic-bezier(0.25, 0.8, 0.25, 1);
box-shadow: 0 10px 20px rgba(0,0,0,0.1);
perspective: 1000px;
transform-style: preserve-3d;
min-height: 300px;
background-size: cover;
background-position: center;
display: flex;
align-items: center;
justify-content: center;
transform: rotate3d(1, 1, 0, 15deg);
}
.bento-box .content {
opacity: 0;
transform: translateY(20px);
transition: all 0.3s ease;
text-align: center;
padding: 20px;
color: white;
text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.bento-box:hover .content {
opacity: 1;
transform: translateY(0);
}
.bento-box:nth-child(1) {
background-image: url('http://static.photos/nature/640x360/1');
}
.bento-box:nth-child(2) {
background-image: url('http://static.photos/technology/640x360/2');
}
.bento-box:nth-child(3) {
background-image: url('http://static.photos/people/640x360/3');
}
.bento-box:nth-child(4) {
background-image: url('http://static.photos/aerial/640x360/4');
}
.bento-box:nth-child(5) {
background-image: url('http://static.photos/green/640x360/5');
}
.bento-box:nth-child(6) {
background-image: url('http://static.photos/blue/640x360/6');
}
.bento-box:hover {
transform: scale(1.05) rotate3d(1, 1, 0, -15deg);
box-shadow: 0 25px 50px rgba(0,0,0,0.25);
filter: blur(2px);
}
.bento-box:hover .content {
opacity: 1;
transform: translateY(0);
filter: none;
}
</style>
</head>
<body class="bg-gradient-to-br from-indigo-50 to-purple-50 min-h-screen">
<div class="container mx-auto px-4 py-12">
<header class="text-center mb-16">
<h1 class="text-5xl font-bold text-indigo-900 mb-4">BentoMotion</h1>
<p class="text-xl text-indigo-700 max-w-2xl mx-auto">Interactive animated bento boxes that respond to your cursor</p>
</header>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8">
<!-- Box 1 -->
<div class="bento-box rounded-2xl overflow-hidden">
<div class="content">
<h3 class="text-2xl font-bold mb-2">Box of Ideas</h3>
<p>Where creativity meets structure</p>
</div>
</div>
<!-- Box 2 -->
<div class="bento-box rounded-2xl overflow-hidden">
<div class="content">
<h3 class="text-2xl font-bold mb-2">Energy Pack</h3>
<p>Boost your productivity</p>
</div>
</div>
<!-- Box 3 -->
<div class="bento-box rounded-2xl overflow-hidden">
<div class="content">
<h3 class="text-2xl font-bold mb-2">Heart Container</h3>
<p>Store your favorite moments</p>
</div>
</div>
<!-- Box 4 -->
<div class="bento-box rounded-2xl overflow-hidden">
<div class="content">
<h3 class="text-2xl font-bold mb-2">Cloud Vault</h3>
<p>Your digital treasures</p>
</div>
</div>
<!-- Box 5 -->
<div class="bento-box rounded-2xl overflow-hidden">
<div class="content">
<h3 class="text-2xl font-bold mb-2">Nature Pod</h3>
<p>A breath of fresh air</p>
</div>
</div>
<!-- Box 6 -->
<div class="bento-box rounded-2xl overflow-hidden">
<div class="content">
<h3 class="text-2xl font-bold mb-2">Stellar Box</h3>
<p>Cosmic wonders</p>
</div>
</div>
</div>
<div class="mt-16 text-center">
<button id="animateAll" class="px-6 py-3 bg-indigo-600 text-white rounded-full hover:bg-indigo-700 transition shadow-lg">
Activate Group Animation
</button>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
feather.replace();
// Individual box hover effects with rotation
const boxes = document.querySelectorAll('.bento-box');
boxes.forEach((box, index) => {
const rotation = [
{ x: 15, y: -15 }, // top-right
{ x: -15, y: 15 }, // bottom-left
{ x: 15, y: 15 }, // top-left
{ x: -15, y: -15 }, // bottom-right
{ x: 20, y: -10 }, // slight variation
{ x: -20, y: 10 } // opposite variation
];
box.addEventListener('mouseenter', function() {
anime({
targets: this,
rotateX: rotation[index].x * 2,
rotateY: rotation[index].y * 2,
rotateZ: rotation[index].x * 0.5,
scale: 1.05,
duration: 500,
easing: 'spring(1, 80, 10, 0)'
});
anime({
targets: this,
filter: 'blur(5px)',
duration: 300
});
});
box.addEventListener('mouseleave', function() {
anime({
targets: this,
rotateX: 0,
rotateY: 0,
rotateZ: 0,
scale: 1,
filter: 'blur(0px)',
duration: 600,
easing: 'easeOutElastic(1, .5)'
});
});
});
// Cursor follower effect
document.addEventListener('mousemove', function(e) {
const cursor = document.createElement('div');
cursor.className = 'cursor-follower';
cursor.style.position = 'fixed';
cursor.style.width = '20px';
cursor.style.height = '20px';
cursor.style.backgroundColor = 'rgba(99, 102, 241, 0.3)';
cursor.style.borderRadius = '50%';
cursor.style.pointerEvents = 'none';
cursor.style.left = e.clientX + 'px';
cursor.style.top = e.client
</body>
</html>