【发布时间】:2016-01-01 12:13:24
【问题描述】:
真正的碳纤维是一系列互锁的灰色纤维,它们看起来像灰色的编织板。请问有谁知道如何在 CSS 中创建这样的模式?
examples by Lea Verou 不是真正的碳纤维,希望您知道“真正的”碳纤维长什么样!
最终我想要实现类似于this background here 的东西。
通过进一步叠加碳纤维背景的梯度。
【问题讨论】:
标签: css linear-gradients
真正的碳纤维是一系列互锁的灰色纤维,它们看起来像灰色的编织板。请问有谁知道如何在 CSS 中创建这样的模式?
examples by Lea Verou 不是真正的碳纤维,希望您知道“真正的”碳纤维长什么样!
最终我想要实现类似于this background here 的东西。
通过进一步叠加碳纤维背景的梯度。
【问题讨论】:
标签: css linear-gradients
可以使用 Lea Verou 使用的相同方法来实现类似于链接网站中存在的渐变模式(它们使用图像作为背景)。
通过在最底层添加一个额外的linear-gradient 图像并将其从较深的黑色阴影变为较浅的阴影,我们可以获得与该网站相同的效果。
注意:该网站还在顶部使用另一层来模糊末端,但我认为您只是在寻找联锁模式。这个额外的层(如果需要)也可以使用 CSS 添加。
body {
background-color: rgb(32, 32, 32);
background-image: linear-gradient(45deg, black 25%, transparent 25%, transparent 75%, black 75%, black), linear-gradient(45deg, black 25%, transparent 25%, transparent 75%, black 75%, black), linear-gradient(to bottom, rgb(8, 8, 8), rgb(32, 32, 32));
background-size: 10px 10px, 10px 10px, 10px 5px;
background-position: 0px 0px, 5px 5px, 0px 0px;
}
如果您需要该网站中效果的精确副本(渐变在左侧和右侧都逐渐变为黑色),则在现有渐变的顶部添加一个额外的图层,使其从黑色变为像下面的 sn-p 一样透明到黑色。
body {
background-color: rgb(32, 32, 32);
background-image: linear-gradient(to right, rgba(0,0,0,1), rgba(0,0,0,0) 20%, rgba(0,0,0,0) 80%, rgba(0,0,0,1)), linear-gradient(45deg, black 25%, transparent 25%, transparent 75%, black 75%, black), linear-gradient(45deg, black 25%, transparent 25%, transparent 75%, black 75%, black), linear-gradient(to bottom, rgb(8, 8, 8), rgb(32, 32, 32));
background-size: 100% 100%, 10px 10px, 10px 10px, 10px 5px;
background-position: 0px 0px, 0px 0px, 5px 5px, 0px 0px;
}
【讨论】: