SCSS箭头带有圆角

发布于 2025-02-11 08:21:36 字数 1492 浏览 1 评论 0原文

我正在尝试从这些箭头,圆形的角箭头中脱颖而出。

这是示例代码:

<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:

arrow

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

花想c 2025-02-18 08:21:36

这种创建箭头的方式不会让您使用/查看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 with border-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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文