scss scss三角混合

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了scss scss三角混合相关的知识,希望对你有一定的参考价值。

//==== Simple SCSS mixin to create CSS triangles
//==== Example: @include css-triangle("up", 10px, #fff);
@mixin css-triangle($direction: "down", $size: 20px, $color: #000) {
    width: 0;
    height: 0;
    border-left: $size solid #{setTriangleColor($direction, "left", $color)};
    border-right: $size solid #{setTriangleColor($direction, "right", $color)};
    border-bottom: $size solid #{setTriangleColor($direction, "bottom", $color)};
    border-top: $size solid #{setTriangleColor($direction, "top", $color)};
}

//Utility function to return the relevant colour depending on what type of arrow it is
@function setTriangleColor($direction, $side, $color) {

    @if $direction == "left" and $side == "right"
    or  $direction == "right" and $side == "left"
    or $direction == "down" and $side == "top"
    or $direction == "up" and $side == "bottom" {
        @return $color
    } @else {
        @return rgba(0,0,0,0);
    }

}

以上是关于scss scss三角混合的主要内容,如果未能解决你的问题,请参考以下文章

scss SCSS,SASS,CSS:保证金混合

使用 SCSS 创建具有动态方向的三角形

scss CSSで三角形

scss 三角形

scss css三角形

scss 三角形CSS