Creating an appealing CSS and adding GSAP animations to your HTML section involves some artistic flair with CSS styles and leveraging GSAP's powerful animation capabilities. Here, I'll provide you with a basic example of CSS styles and GSAP animations.
CSS Styles
First, let's deal with the CSS to create a visually attractive layout.
body {
font-family: 'Arial', sans-serif;
margin: 0;
padding: 0;
background-color: #f4f4f9;
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
}
h2 {
text-align: center;
color: #333;
margin-bottom: 40px;
}
.goods__blocks, .goods__hire {
display: flex;
justify-content: space-between;
align-items: center;
flex-wrap: wrap;
margin-bottom: 30px;
}
.goods__block, .goods__hire {
background-color: #fff;
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
border-radius: 8px;
overflow: hidden;
flex-basis: 48%;
transition: transform 0.3s ease;
}
.goods__block:hover, .goods__hire:hover {
transform: translateY(-10px);
}
.gbg, .gbg2 {
padding: 20px;
}
h3 {
color: #007bff;
margin-bottom: 10px;
}
p {
color: #555;
line-height: 1.6;
}
button {
background-color: #007bff;
color: white;
border: none;
padding: 10px 20px;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s ease;
}
button:hover {
background-color: #0056b3;
}
.goods_blocki {
max-width: 200px;
}
.goods_blocki img {
width: 100%;
border-radius: 0 0 8px 8px;
}
GSAP Animation
To animate this layout using GSAP, include the GSAP library, and you can create animations for when the page loads or specific elements come into view.
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.11.0/gsap.min.js"></script>
// GSAP animations
document.addEventListener('DOMContentLoaded', () => {
gsap.from(".goods__block, .goods__hire", {
duration: 1,
opacity: 0,
y: 20,
stagger: 0.2,
ease: "power2.out"
});
gsap.from("h2", {
duration: 1,
opacity: 0,
y: -20,
ease: "power2.out"
});
gsap.to("button", {
scale: 1.05,
repeat: -1,
yoyo: true,
ease: "power1.inOut",
duration: 0.5,
});
});
Explanation
-
CSS Styling: The CSS provides a clean, modern look with subtle box shadows and hover effects. It ensures that the content is neatly laid out and the colors help in visually distinguishing different sections.
-
GSAP Animations: GSAP animates the entry of goods blocks and buttons with staggered appearances for a more dynamic look and feel. The buttons have a gentle scaling effect that makes them more interactive.
This setup will make your goods section visually appealing and engaging with smooth transitions and interactions. Adjust styles and animations as needed to fit your aesthetic or branding.