SCSS箭头带有圆角
我正在尝试从这些箭头,圆形的角箭头中脱颖而出。
这是示例代码:
<div class="container">
<span class="calendar-arrow calendar-arrow-left"></span>
<span class="calendar-arrow calendar-arrow-right"></span>
</div>
SCSS是:
@mixin arrow($direction) {
width: 0;
height: 0;
border-style: solid !important;
border-style: inset;
-webkit-transform: rotate(360deg);
border-radius: 3px; /* this does not work well */
@if $direction == left {
border-width: 6px 8px 6px 0;
border-color: transparent #8f9cbc transparent transparent;
}
@if $direction == right {
border-width: 6px 0 6px 8px;
border-color: transparent transparent transparent #8f9cbc;
}
}
.container {
display: flex;
width: 400px;
height: 200px;
background: yellow;
.calendar-arrow-left {
@include arrow(left);
position: absolute;
top: 28px;
left: 20px;
}
.calendar-arrow-right {
@include arrow(right);
position: absolute;
top: 28px;
left: 40px;
}
}
我已经搜索了其他解决方案,但是它们似乎具有内容:''
属性。 我想知道是否可以修复上述代码,而无需使用content
。
感谢您的帮助。
这是 codepen 。
编辑:这些是我需要创建的箭头的尺寸:
I am trying to make out of these arrows, rounded corner arrows.
Here is the sample code:
<div class="container">
<span class="calendar-arrow calendar-arrow-left"></span>
<span class="calendar-arrow calendar-arrow-right"></span>
</div>
And the scss is:
@mixin arrow($direction) {
width: 0;
height: 0;
border-style: solid !important;
border-style: inset;
-webkit-transform: rotate(360deg);
border-radius: 3px; /* this does not work well */
@if $direction == left {
border-width: 6px 8px 6px 0;
border-color: transparent #8f9cbc transparent transparent;
}
@if $direction == right {
border-width: 6px 0 6px 8px;
border-color: transparent transparent transparent #8f9cbc;
}
}
.container {
display: flex;
width: 400px;
height: 200px;
background: yellow;
.calendar-arrow-left {
@include arrow(left);
position: absolute;
top: 28px;
left: 20px;
}
.calendar-arrow-right {
@include arrow(right);
position: absolute;
top: 28px;
left: 40px;
}
}
I have searched other solutions, but they seem to have the content:''
property.
I am wondering if it is possible to fix the above code, without the need to use content
.
I would appreciate your help.
Here is a codepen.
Edit: these are the sizes of the arrow I need to create:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这种创建箭头的方式不会让您使用/查看
border-radius
ie圆角,因为您正在使用透明的边框。您也许可以用border-radius
将其他两个角落四舍五入,除了尖头(&lt;&gt;),因为这甚至不是“真实”指向您看到的,因此它们出现在结果透明度和实际(边界)角是隐藏的。要解决此问题,您需要使用
transform
和:
之前:
pseudo元素以创建箭头。jsfiddle
This way of creating arrows won't let you use/see
border-radius
i.e. rounded corners because you are using transparent borders. You might be able to get the other 2 corners rounded withborder-radius
except the pointed ones (< >) because that is not even 'real' pointing you are seeing, they appear as a result of transparency and actual (border) corners are hidden.To counter this issue you need to use
transform
and:before
:after
pseudo elements to create arrows.JSFiddle