P粉3928610472023-08-30 10:51:11
This is possible, and it requires no additional markup , but uses the ::after
pseudo-element .
It involves placing a pseudo-element with a gradient background underneath and cropping it. This works for all browsers that currently don't have vendor prefixes or hacks (even IE), but if you want to support retro versions of IE, you should consider solid color fallbacks, javascript, and/or custom MSIE CSS extensions (i.e.
Filters, CSSPie - such as vector spoofing, etc.).
jsfiddle version):
@import url('//raw.githubusercontent.com/necolas/normalize.css/master/normalize.css'); html { /* just for showing that background doesn't need to be solid */ background: linear-gradient(to right, #DDD 0%, #FFF 50%, #DDD 100%); padding: 10px; } .grounded-radiants { position: relative; border: 4px solid transparent; border-radius: 16px; background: linear-gradient(orange, violet); background-clip: padding-box; padding: 10px; /* just to show box-shadow still works fine */ box-shadow: 0 3px 9px black, inset 0 0 9px white; } .grounded-radiants::after { position: absolute; top: -4px; bottom: -4px; left: -4px; right: -4px; background: linear-gradient(red, blue); content: ''; z-index: -1; border-radius: 16px; }
<p class="grounded-radiants"> Some text is here.<br/> There's even a line break!<br/> so cool. </p>
,
inset
P粉9523651432023-08-30 00:07:25
According to W3C specification, it may not be possible:
This may be because border-image
can take on some potentially complex patterns. If you want a circular image border, you'll need to create one yourself.