Are border gradients compatible with border-radius?
P粉824889650
2023-08-21 20:39:38
<p>I'm styling an input box with a rounded border (border-radius) and trying to add a gradient effect to the border. I can successfully create gradient and rounded borders, but not both at the same time. Either there are rounded corners but no gradient, or there is a gradient but no rounded corners. </p>
<pre class="brush:php;toolbar:false;">-webkit-border-radius: 5px;
-webkit-border-image: -webkit-gradient(linear, 0 0, 0 100%, from(#b0bbc4), to(#ced9de)) 1 100%;</pre>
<p>Is there a way to have these two CSS properties take effect at the same time, or is this not possible? </p>
This is possible, and requires no additional markup , but instead uses a
::after
pseudo-element .filter
This is a live example (, CSSPie-like vector tricks, etc.).
jsfiddle version):
This works on any background-
It works well with - box-shadow
No need for you to add shadow to pseudo-element-
Again, this applies to IE, Firefox and Webkit/Blink browsers., with or without
insetProbably not possible, according to W3C specification:
This may be because
border-image
can adopt some potentially complex patterns. If you want a circular image border, you need to create one yourself.