Skip to content

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
  • No Access
  • Privacy Policy
CSS

CSS: Use Box Shadow for Depth and Elevation

- 14.06.26 - ErcanOPAK

🎚️ Flat Design is Out, Depth is In

Box shadow adds depth. Elevation levels communicate hierarchy. Cards hover higher, modals highest. Better UX.

📝 Shadow Syntax

/* offset-x | offset-y | blur-radius | spread-radius | color */
box-shadow: 2px 2px 5px 0 rgba(0,0,0,0.1);

/* Multiple shadows (layered) */
box-shadow: 
  0 2px 4px rgba(0,0,0,0.1),
  0 8px 16px rgba(0,0,0,0.1);

/* Inset shadow (inner) */
box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);

/* Elevation levels */
.elevation-1 { box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24); }
.elevation-2 { box-shadow: 0 3px 6px rgba(0,0,0,0.15), 0 2px 4px rgba(0,0,0,0.12); }
.elevation-4 { box-shadow: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23); }
.elevation-8 { box-shadow: 0 19px 38px rgba(0,0,0,0.30), 0 15px 12px rgba(0,0,0,0.22); }

🎯 Interactive Shadows

/* Hover effect */
.card {
  transition: box-shadow 0.3s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.card:hover {
  box-shadow: 0 8px 16px rgba(0,0,0,0.2);
  transform: translateY(-2px);
}

/* Focus state */
button:focus {
  box-shadow: 0 0 0 3px rgba(66,153,225,0.5);
}

/* Neumorphism (soft UI) */
.neumorph {
  background: #e0e0e0;
  box-shadow: 
    20px 20px 60px #bebebe,
    -20px -20px 60px #ffffff;
}

💡 Performance Note

  • Use blur-radius sparingly (large blurs are expensive)
  • Animate transform, opacity, not box-shadow (expensive)
  • Use will-change: transform for animated shadows
  • Multiple shadows increase rendering cost

“Flat design felt cheap. Added box shadows for depth. Cards now look elevated, buttons feel clickable. Shadows improve UX perception.”

— UI Designer

Related posts:

CSS: Use will-change to Optimize Animations Before They Start

Use clamp() for Perfect Responsive Font Sizes

CSS Padding and Margin 4 Values and What happens if some of them are omitted

Post Views: 3

Post navigation

Windows 11: Use File Explorer Tabs to Organize Multiple Folders
HTML: Use Lang Attribute for Accessibility and SEO

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

July 2026
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  
« Jun    

Most Viewed Posts

  • Get the User Name and Domain Name from an Email Address in SQL (960)
  • How to add default value for Entity Framework migrations for DateTime and Bool (898)
  • How to make theater mode the default for Youtube (858)
  • Get the First and Last Word from a String or Sentence in SQL (840)
  • How to select distinct rows in a datatable in C# (814)
  • How to enable, disable and check if Service Broker is enabled on a database in SQL Server (597)
  • Add Constraint to SQL Table to ensure email contains @ (582)
  • Average of all values in a column that are not zero in SQL (545)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (512)
  • Find numbers with more than two decimal places in SQL (460)

Recent Posts

  • C#: Use Using Statements for Resource Management
  • C#: Use Lambda Expressions for Concise Code
  • SQL: Use GROUP BY for Data Aggregation
  • .NET Core: Master Routing for Clean URLs
  • Git: Use Reset to Undo Local Changes
  • Ajax: Use Axios for HTTP Requests
  • JavaScript: Understand Hoisting
  • HTML: Use Web Storage for Client-Side Data
  • CSS: Use Filter Effects for Visual Magic
  • Windows 11: Unlock God Mode for All Settings

Most Viewed Posts

  • Get the User Name and Domain Name from an Email Address in SQL (960)
  • How to add default value for Entity Framework migrations for DateTime and Bool (898)
  • How to make theater mode the default for Youtube (858)
  • Get the First and Last Word from a String or Sentence in SQL (840)
  • How to select distinct rows in a datatable in C# (814)

Recent Posts

  • C#: Use Using Statements for Resource Management
  • C#: Use Lambda Expressions for Concise Code
  • SQL: Use GROUP BY for Data Aggregation
  • .NET Core: Master Routing for Clean URLs
  • Git: Use Reset to Undo Local Changes

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com