π Day 16 of 200 Days of Code: Keeping It Light, Staying Consistent
Not every day has to be packed with hours of coding and dozens of new concepts. Today was light, but consistent β and thatβs what truly matters in a long-term journey like this one.
On Day 16 of my full-stack journey, I focused on just two powerful features in CSS:
- Box shadows using the
box-shadow
property - CSS variables (also called custom properties)
Even in just a short session, I learned how these small tools can make a big visual difference and improve my workflow.
βοΈ Adding Depth with CSS box-shadow
The box-shadow
property lets you add drop shadows to elements, giving them a sense of depth and elevation β a simple way to make your UI look more polished.
π Syntax:
box-shadow: offset-x offset-y blur-radius color;
You can also add spread and inset values:
box-shadow: offset-x offset-y blur-radius spread-radius color inset;
β Basic Example:
.card {
box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.2);
}
This adds a soft gray shadow offset 4px to the right and 4px down.
π¨ Multiple Shadows:
You can even stack multiple shadows!
button {
box-shadow: 2px 2px 5px rgba(0,0,0,0.1),
-2px -2px 5px rgba(255,255,255,0.7);
}
This creates a subtle 3D, neumorphic-style effect.
π Inset Shadow:
input {
box-shadow: inset 0 2px 5px rgba(0,0,0,0.1);
}
inset
makes the shadow appear inside the element, often used in inputs or cards for inner glow effects.
π― Introducing CSS Variables (Custom Properties)
CSS variables allow you to define values once and reuse them across your styles β a game-changer for consistency and maintainability in large projects.
π Syntax:
:root {
--primary-color: #3498db;
--card-padding: 20px;
}
.card {
background-color: var(--primary-color);
padding: var(--card-padding);
}
β Why CSS Variables Are Awesome:
- Easy to update theme colors or layout settings
- Great for dark/light modes
- Reduces repetition in your code
π‘ Local vs Global Variables:
/* Global */
:root {
--text-color: #333;
}
/* Local */
.container {
--text-color: #000;
color: var(--text-color); /* uses local value */
}
The value of a CSS variable can be overridden within a specific selector, making them very flexible.
π§ββοΈ A Small Win Is Still a Win
Some days are for big breakthroughs, others are just about showing up. Today, I learned something new, practiced what I learned, and kept the momentum going. Thatβs what progress looks like.
βYou donβt have to be extreme, just consistent.β
Tomorrow, I might dig deeper into CSS transitions or responsive design β but for now, Iβm glad I kept the streak alive.
π‘ Quick Recap
- β
Learned how to use
box-shadow
to create depth and style - β Explored CSS variables for more maintainable and scalable code
π Resources to Dive Deeper
π What's Next?
Have you used box-shadow
creatively in your projects? Tried out CSS variables in theming? Let me know in the comments or share your tips!
Until tomorrow, happy coding! π»
#CSS #WebDevelopment #FrontendDev #100DaysOfCode #CodingJourney #LearnToCode
Top comments (0)