Can we use box-shadow to create stretched shadow?

Is it possible to create a stretched shadow for any element in html using box-shadow like in shared image.
8 Replies
Kevin Powell
Kevin Powell•2y ago
you can, but if you're using regular CSS it's a bit annoying 😅 https://codepen.io/kevinpowell/pen/xxQpMox/a56b39ab438ee1ad13e3e448abd53e5e A lot easier with Sass 😅
Rägnar O'ock
Rägnar O'ock•2y ago
good old "add a shadow for each pixel of length you need"
Tok124 (CSS Nerd)
Tok124 (CSS Nerd)•2y ago
You can also create a sass function like this
@function shadow($color, $repeats) {
$value:();
@for $i from 1 through $repeats {
$value:append($value, #{$i}px #{$i}px #{$color}, comma);
}
@return $value;
}
@function shadow($color, $repeats) {
$value:();
@for $i from 1 through $repeats {
$value:append($value, #{$i}px #{$i}px #{$color}, comma);
}
@return $value;
}
If you want to use it on multiple places So then you can use it like text-shadow:shadow(#000, 30);
Joao
Joao•2y ago
That is such a cool trick!
AparAwasthi
AparAwasthiOP•2y ago
Thanks @Kevin @tok124 , but now it makes me think that if shadow is an efficient way to create this effect?
Rägnar O'ock
Rägnar O'ock•2y ago
Outside of using an svg (or maybe a special font... But i'm not sure if it's possible or not) there's hardly any other way
AparAwasthi
AparAwasthiOP•2y ago
Thank you guys
Want results from more Discord servers?
Add your server