WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED WORKSFORME
20127
Add CSS gradient support for borders
https://bugs.webkit.org/show_bug.cgi?id=20127
Summary
Add CSS gradient support for borders
John Engelhart
Reported
2008-07-21 11:51:26 PDT
While working with the new CSS gradient support, I found that it would be extremely useful to be able to specify a fill gradient for the borders colors. This allows you to trivially create relief effects. For example, a gradient that's white to black with a low alpha allows one to create a good looking button relief effect. Combined with border-radius, you can create very good looking buttons. I ended up creating the effect in a canvas by manually drawing what would normally be the border, but it's obviously much better if you can just do it natively with the border without having to resort to such hackery. Conceptually, the border becomes a mask, and the gradient is used for the fill. This is slightly different than the more intuitive notion of stroking the border. By having the border be a mask, you can apply a consistent gradient fill for all of them. The trivial case where all the borders are the same color is easy, I suspect that 'multi-color/gradient' borders would group borders that share a common gradient specification, and fill those at the same time in one pass. I found it very useful to use border-radius along with a multi-stop fill. For a 'white highlight at top, dark highlight at bottom', it looked very good when the top and bottom highlights could taper off over the size of the border radius. So, at the top, the white highlight transitioned to the side highlight over the length of the border radius, and the side highlight just very slightly darken over the length of the left and right border, and repeat the border radius transition at the bottom. When the border radius is specified with something like '0.5em', along with the corresponding gradient stops, this allows you to create resolution independent relief effects that scale very cleanly with a uses chosen text size. In safari, 'Make Text Bigger' and 'Make Text Smaller' causes the effect to scale perfectly. Oval buttons are essentially just a special case when the sides are only effectively 0.5em high, and the entire edge is bent along the radius, no straight segments. Same thing, really. Once I started playing with this, I kept thinking to myself "Now if I could just have a procedural shader!"
Attachments
Add attachment
proposed patch, testcase, etc.
Sam Weinig
Comment 1
2008-07-21 16:17:09 PDT
I believe this should be possible using border-image and CSS Gradients.
Simon Fraser (smfr)
Comment 2
2009-08-10 14:15:39 PDT
I don't think you can get the same effect with border image and CSS gradients.
Erik Arvidsson
Comment 3
2010-05-25 13:10:19 PDT
Yeah, border image is not for images in the border but a way to do a nine-grid background images. I think we need a proposal for the CSS to do this.
Erik Arvidsson
Comment 4
2011-03-21 19:01:00 PDT
I think the problem is that we do not correctly support border-image. To be more specific, border-image-slice seems to be missing completely leading us to always fill the center.
http://dev.w3.org/csswg/css3-background/#the-border-image-slice
It seems like implementing this correctly will break existing usages of -webkit-border-image.
Simon Fraser (smfr)
Comment 5
2011-03-21 20:13:28 PDT
See
bug 52736
.
Erik Arvidsson
Comment 6
2011-10-06 09:29:00 PDT
This is now doable with border-image <style> #a { display: inline-block; border-width: 2px; border-image-source: -webkit-linear-gradient(#aaa, #333); border-image-slice: 2; background: -webkit-linear-gradient(#eee, #aaa); padding: 2px 5px } </style> <div id=a>Hello World</div>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug