如何使用剪切边缘创建按钮&圆角?
根据设计,我正在尝试创建一个按钮,但是在圆角方面遇到了一些麻烦。
因此,我需要实现一个按钮,看起来像这样: 按钮视图
我试图通过Linearear-Gradient < /代码>,这种方式
.button {
width: 210px;
height: 45px;
outline: none;
border: 1px solid #389F96;
background:
linear-gradient(-45deg, black, black, 30px, transparent 0px),
linear-gradient(135deg, black, black, 30px, transparent 0px),
linear-gradient(to bottom, #389F96, #46C1EE);
}
<button class="button">Log in</button>
但是在这种情况下,border-radius
使我以不正确的方式将其围成一圈,
因此我需要创建一个这样的按钮(带有圆角,切割的边缘,带有线性梯度边框)。
是否有一些“简单的方法”来处理它?
I'm trying to create a button, according to design but have some trouble with rounding corners.
So I need to implement a button, which looks like this:
Button view
I was trying to cut edges and set background color via linear-gradient
, this way
.button {
width: 210px;
height: 45px;
outline: none;
border: 1px solid #389F96;
background:
linear-gradient(-45deg, black, black, 30px, transparent 0px),
linear-gradient(135deg, black, black, 30px, transparent 0px),
linear-gradient(to bottom, #389F96, #46C1EE);
}
<button class="button">Log in</button>
But in this case, border-radius
make it round in an incorrect for me way
So I need to create a button like this (with rounded corners, cut edges, and with linear gradient border).
Is there some "easy way" to handle it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果按钮的尺寸始终相同(正如您的CSS所建议的那样),我会考虑使用SVG作为背景。
使用伪元转换
我能够实现的最相似的结果是基于 Temani Afif的评论 :
带有SVG过滤器的剪辑 -
基于 克隆评论 and nofollow noreferrer“> temani afif” /a>我实现了这一点:
我根据您的评论提供了解决方案,因为您没有提供任何答案。如果您将其添加为答案,我将删除我的。
If the button will always be the same size (as your CSS suggests), I would think about using SVG as background.
Transform with pseudoelement
The most similar result I was able to achieve is based on Temani Afif's comment:
Clip-path with SVG filter
Based on cloned comment and Temani Afif's article I achieved this:
I have provided a solution based on your comments because you have not provided any answer. If you add it as an answer I will delete mine.