CSS Shadows
In this page:
selector {
box-shadow: h-offset v-offset blur spread color;
text-shadow: h-offset v-offset blur color;
}
box-shadow Syntax
box-shadow property आपके element containers में एक shadow जोड़ती है। यह shadow define करने के लिए पाँच values इस्तेमाल करती है: horizontal offset, vertical offset, blur radius (shadow कितना soft दिखता है), spread radius (यह कितना बड़ा expand होता है), और color।
- अपने elements को realistic दिखाने के लिए soft, semi-transparent black shadows (जैसे rgba(0,0,0,0.1)) इस्तेमाल करें।
- Accepted values:
- <offset-x> <offset-y> — ज़रूरी horizontal और vertical offsets
- <blur-radius> — optional, बड़ा value softer
- <spread-radius> — optional, shadow को बढ़ाता या घटाता है
- <color> — shadow color (default currentcolor)
- inset — shadow को box के अंदर draw करता है
- none — कोई shadow नहीं (default)
- inherit | initial | unset | revert — हर property द्वारा accepted CSS-wide keywords
उदाहरण: The box-shadow Syntax
<style>
.box {
background: white;
padding: 16px;
box-shadow: 2px 4px 8px 0px gray;
}
</style>
<div class="box">Shadowed box</div>
कई Shadows इस्तेमाल करना
आप उनकी declarations को commas से अलग करके एक ही element पर कई overlapping shadows लागू कर सकते हैं, जिससे आप rich, realistic depth effects बना सकते हैं।
- realistic lighting depth बनाने के लिए एक छोटा, dark shadow को एक बड़े, soft shadow के साथ combine करें।
- Accepted values:
- box-shadow: A, B — comma-separated list, पहली सबसे ऊपर है
- none — कोई shadows नहीं
- inset — कोई भी layer inner हो सकती है
- <color> — हर layer का अपना color है
- inherit | initial | unset | revert — हर property द्वारा accepted CSS-wide keywords
उदाहरण: Using Multiple Shadows
<style>
.box {
background: white;
padding: 16px;
box-shadow: 1px 1px 2px rgba(0,0,0,0.3), 0 8px 16px rgba(0,0,0,0.15);
}
</style>
<div class="box">Layered shadows for depth</div>
text-shadows लागू करना
text-shadow property text characters पर सीधे shadows लागू करती है। यह तीन values इस्तेमाल करती है: horizontal offset, vertical offset, और blur radius, उसके बाद shadow color।
- light background images पर रखे जाने पर white headers को readable बनाने के लिए एक subtle text-shadow इस्तेमाल करें।
- Accepted values:
- <offset-x> <offset-y> — ज़रूरी offsets
- <blur-radius> — optional blur
- <color> — optional color (default currentcolor)
- A, B — कई shadows के लिए comma-separated list
- none — कोई shadow नहीं (default)
- inherit | initial | unset | revert — हर property द्वारा accepted CSS-wide keywords
उदाहरण: Applying text-shadows
<style>
h1 {
text-shadow: 2px 2px 4px black;
}
</style>
<h1>Shadowed Text</h1>
Pressed Inset Shadows
Default रूप से, box-shadows आपके elements के बाहर render होते हैं। अपनी box-shadow declaration की शुरुआत में inset keyword जोड़कर, आप browser को shadow को अंदर cast करने का instruction देते हैं, element को pressed या page में sunken जैसा दिखाते हुए।
- active, pressed button states या form input fields को साफ़ तरीके से style करने के लिए inset shadows इस्तेमाल करें।
- Accepted values:
- inset — shadow को padding edge के अंदर draw करता है
- <offset-x> <offset-y> — जिस दिशा में inner shadow पड़ता है
- <blur-radius> — inner edge की softness
- <spread-radius> — inner shadow की thickness
उदाहरण: Pressed Inset Shadows
<style>
.button {
background: #ddd;
padding: 16px;
box-shadow: inset 2px 2px 4px gray;
}
</style>
<div class="button">Pressed / inset look</div>
Neumorphic Border Layout
Neumorphism एक modern web design style है जो soft, plastic-like layouts बनाती है। top-left पर एक light shadow को bottom-right पर एक dark shadow के साथ combine करके, आप elements को page background से सीधे mould किए गए जैसा दिखाते हैं।
- Neumorphism को आपके element के background color को page background color से exactly match करना चाहिए।
- Accepted values:
- box-shadow: A, B — दो comma-separated shadows (light और dark)
- negative offsets — top-left की तरफ़ light shadow
- positive offsets — bottom-right की तरफ़ dark shadow
- inset — effect को pressed look में flip करता है
उदाहरण: The Neumorphic Border Layout
<style>
.box {
background: #e0e0e0;
box-shadow: -6px -6px 12px white, 6px 6px 12px rgba(0,0,0,0.2);
}
</style>
<div class="box">Neumorphic box</div>
- solid, dark black shadows इस्तेमाल करना, जो harsh और artificial दिखते हैं।
- छोटे body text पर text-shadows लागू करना, इसे blurry और पढ़ना मुश्किल बनाते हुए।
- high-contrast neumorphic styles इस्तेमाल करना जो web accessibility contrast guidelines को fail कर देते हैं।
- box-shadow property container boxes में shadows जोड़ती है, और text-shadow text characters में shadows जोड़ती है।
- realistic depth के लिए offsets, एक blur radius, और एक semi-transparent RGBA color इस्तेमाल करके अपने shadows specify करें।
- elements के अंदर shadows cast करने के लिए inset keyword जोड़ें, और neumorphic designs बनाने के लिए light और dark shadows combine करें।
Standard CSS box-shadow, text-shadow, और inset properties हर modern web browser द्वारा natively supported हैं।
Chapter Quiz — Complete all 22 topics to unlock
0/22 topics done
Complete these topics first:
- CSS Gradients
- CSS Shadows
- CSS Filters
- CSS Blend Modes
- CSS Transforms
- CSS 2D Transforms
- CSS 3D Transforms
- CSS Transitions
- CSS Animations
- CSS Image Styling
- CSS Image Effects
- CSS Hover Overlays
- CSS Image Modal
- CSS Image Centering
- CSS Image Shapes
- CSS Buttons
- CSS Columns
- CSS Clip Path
- CSS Shapes
- CSS Scroll Snap
- CSS Architecture: BEM
- CSS Custom Properties