gpt4 book ai didi

html - 如何使用带边框图像的径向渐变

转载 作者:行者123 更新时间:2023-11-28 00:44:56 25 4
gpt4 key购买 nike

我正在尝试使用源为径向渐变的边框图像。我看过很多带有图像的示例,但没有看到带有径向渐变的示例。

My CodePen 中的完整示例

#main {
width: 200px;
border: 8px solid red;
padding: 10px;
border-image:
radial-gradient( farthest-corner, #777 50%, #7770 60%) /* source */
28 / /* slice */
8px 8px 8px 8px / /* width */
4px 4px 4px 4px /* outset */
round; /* repeat */
}

我只想用间隔几个像素的小圆圈包围盒子,最好使用纯 CSS 解决方案。虽然我很高兴听到其他问题

最佳答案

你可以用这样的背景来做:

#main {
width: 200px;
padding:10px;
background:
radial-gradient(circle at center, #777 60%, transparent 61%) top left/10px 10px repeat-x,
radial-gradient(circle at center, #777 60%, transparent 61%) bottom left/10px 10px repeat-x;
}
<div id="main">This element is surrounded by a radial-gradient-based border image!</div>

如果你想要所有的边,你可以这样做:

#main {
width: 200px;
padding:13px 10px;
background:
radial-gradient(circle at center, #777 60%, transparent 61%) top left/10px 10px repeat-x,
radial-gradient(circle at center, #777 60%, transparent 61%) bottom left/10px 10px repeat-x,
radial-gradient(circle at center, #777 60%, transparent 61%) bottom left/10px 10px repeat-y,
radial-gradient(circle at center, #777 60%, transparent 61%) bottom right/10px 10px repeat-y;
}
<div id="main">This element is surrounded by a radial-gradient-based border image!</div>

关于html - 如何使用带边框图像的径向渐变,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51158727/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com