是否可以制作渐变边框?
正如标题所述,是否可以在 CSS3 中制作渐变边框,如果可以的话如何制作? 我知道你可以制作渐变背景,并且有很多生成器可以实现这一点,但我还没有找到一个可以创建渐变边框代码的生成器。
As the title states, is it possible to make a gradient border in CSS3 and if so how?
I know that you can make gradient backgrounds and there are many generators for that, but I am yet to find one that creates the code for a gradient border.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(10)
1.
嗯.. 这不是花哨的 css3,但这里有一个可能的解决方案:
我之前为其他东西制作了这个示例,我只是更改了
#childWrap
http://jsfiddle.net/qD4zd/1/ (请注意,渐变不是很灵活,因为它是用图像完成的。)
基本思想是那如果您想要使用带有渐变、图案或图像的边框来框住元素,则应该将该元素包装在另一个用作边框的元素内。
2.
更灵活的渐变:您可能想尝试的另一件事是 http://www.css3pie.com并使用外部元素中的渐变背景创建边框,如我的示例 jsfiddle 中所示。
或
http://www.colorzilla.com/gradient-editor/
( http://jsfiddle.net/qD4zd/2/ )
3.
第三点..第一种方法可以是制作成更多通过使用实际的
标签进行灵活的调整,以便您强制图像具有特定的高度和宽度..甚至看起来不错。
1.
Well.. this is no fancy css3 but heres one possible solution:
I made this example for something else before and i just changed the background url of
#childWrap
http://jsfiddle.net/qD4zd/1/ ( note that the gradient isnt very flexible as it is done with images. )
Basic idea is that if you have element that you want to frame with a border with a gradient, pattern or just image you should wrap that element inside another which you will use as the border.
2.
A little more flexible gradient: Another thing you might want to try is http://www.css3pie.com and use the gradient background in outer element to create a border like in my example jsfiddle.
OR
http://www.colorzilla.com/gradient-editor/
( http://jsfiddle.net/qD4zd/2/ )
3.
On a third note.. The first method could be made into more flexible one by using actual
<img>
tag so that you force the image to be specific height and width.. could even look decent.下面是使用 CSS3 创建渐变阴影边框的可能性:
实际上,这将在边缘处创建一个半径为 10px 的内部阴影边框。
Here is a possibility to create a gradient shadow border with CSS3:
Practically this will create an inner shadow border with 10px radius at the edges.
无需做太多事情,只需添加以下代码即可:
只需将上述代码添加到元素中,border-image-slice 属性将设置元素的内部偏移量。
Nothing to do much just add following code:
just add above code to the element and border-image-slice property will set the inner offsets of the element.
带有线性渐变的边框。
HTMLCSS
Border with linear gradient.
HTML
CSS
你可以试试这个:
You can try this:
这里是一个在 Firefox 下工作的渐变边框的例子:
在你的 CSS 中尝试类似的东西,让它工作。
编辑:我不确定它是否适用于其他浏览器。
here is an example of a gradient border that would work under Firefox:
Try something like that in your CSS for it to work.
EDIT: I'm not sure if it will work at all on other browsers.
可能对你来说是其他工作,但我有非常简单的提示,只需将背景图像替换为边框图像即可
may be other work for you but i have very simple tips for you just replace background-image to border-image like
我通过设置其 css 属性使用 span 元素作为边框。下面是我的代码
,这是我的 css -
此代码将生成如下输出 https://drive.google.com/file/d/0B2sRswnexZtfUVlTM0t2dWI3cjA/edit?usp=sharing
i used the span element instead to use as border by setting its css property. below is my code
n here is my css -
this code will generate the output like this https://drive.google.com/file/d/0B2sRswnexZtfUVlTM0t2dWI3cjA/edit?usp=sharing
这是一个创建彩色渐变边框的解决方案,就像您在 Gumroad 或 Vimeo 等网站顶部看到的那样,例如:
Codepen:彩色 CSS 渐变边框,类似 Gumroad 或 Vimeo
渐变 < em>可以用双停止符号写成一半的大小,以这种方式:
……不幸的是,Safari 还不支持这种语法。
Here's a solution that creates a colorful gradient border, like you can see at the top of sites such as Gumroad or Vimeo, e.g.:
Codepen: Colorful CSS gradient border, à la Gumroad or Vimeo
The gradient could be written in half the size with the double stop notation, in this fashion:
…unfortunately, such syntax is not supported by Safari as of yet.
只需使用::之前
Just use ::before