1. CSS Variables Magic 🎨
💡 Tip: Define reusable values with --custom-properties, then use them throughout your CSS!
:root {
--main-color: #ff6347;
}
body {
background-color: var(--main-color);
}
Let me explain using Proper Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CSS Variables Magic 🎨</title>
<style>
:root {
--main-color: #ff6347;
--accent-color: #00bfff;
--text-color: #ffffff;
}
body {
background-color: var(--main-color);
color: var(--text-color);
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
.box {
background-color: var(--accent-color);
padding: 50px;
border-radius: 10px;
text-align: center;
font-size: 1.5em;
}
</style>
</head>
<body>
<div class="box">
This box uses CSS Variables! 🎨
</div>
</body>
</html>
Output:
2. The Hidden Hover Effect 🕵️♀️
🎉 Hover effects without adding hover in CSS? Try :not() with child selectors for stealthy hover interactions!
button:not(:hover) {
background-color: #ddd;
}
Let me explain using Proper Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hidden Hover Effect with :not()</title>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f5f5f5;
}
.container {
display: flex;
gap: 10px;
}
.box {
width: 100px;
height: 100px;
background-color: #3498db;
transition: background-color 0.3s ease, transform 0.3s ease;
}
/* The hidden hover effect */
.box:hover {
transform: scale(1.1);
}
.box:not(:hover) {
background-color: #e74c3c; /* Changes all other boxes except the hovered one */
}
</style>
</head>
<body>
<div class="container">
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
</div>
</body>
</html>
Output:
After hovering:
3. Border-Radius Hacks 🎯
🔥 Want perfect circles or pill-shaped buttons? Play with percentages in border-radius to create ultra-smooth shapes!
.circle {
border-radius: 50%;
}
.pill {
border-radius: 50% / 25%;
}
Let me explain using Proper Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Border-Radius Hacks 🎯</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
margin: 0;
gap: 20px;
}
.circle {
width: 100px;
height: 100px;
background-color: #ff6347;
border-radius: 50%;
display: flex;
justify-content: center;
align-items: center;
color: #fff;
font-weight: bold;
}
.pill {
width: 200px;
height: 50px;
background-color: #00bfff;
border-radius: 50% / 25%;
display: flex;
justify-content: center;
align-items: center;
color: #fff;
font-weight: bold;
}
</style>
</head>
<body>
<div class="circle">●</div>
<div class="pill">Pill Shape 🎯</div>
</body>
</html>
4. SVGs as Backgrounds 📐
🚀 Ditch static images! Use inline SVGs to create scalable, sharp backgrounds without slowing your site down!
background: url('data:image/svg+xml,...');
Let me explain using Proper Code:
Continue Reading "🔥 CSS Tricks: Top 10 Mind-Blowing Front-End Hacks That will Blow Your Mind! 🔥"
Top comments (0)