Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

移动端 vw 布局实现 1px 边框线的 scss mixin #28

Open
yinxin630 opened this issue Nov 4, 2019 · 0 comments
Open

移动端 vw 布局实现 1px 边框线的 scss mixin #28

yinxin630 opened this issue Nov 4, 2019 · 0 comments
Labels

Comments

@yinxin630
Copy link
Owner

yinxin630 commented Nov 4, 2019

mixin 定义

$border-poses: top, right, bottom, left;
$border-color: #eee;
@mixin border-1px($color: $border-color, $poses: $border-poses) {
    position: relative;
    &::after {
        content: '';
        display: block;
        position: absolute;
        width: 100%;
        @each $pos in $poses {
            border-#{$pos}: 1px solid $color;
            #{$pos}: 0;
        }
        @if $poses == 'top' or $poses == 'bottom' {
            left: 0;
            right: 0;
            transform: scaleY(0.5);
        }
        @if $poses == 'left' or $poses == 'right' {
            top: 0;
            bottom: 0;
            transform: scaleX(0.5);
        }
    }
}

用法

<div class="need-1px-border">需要1px边框线的元素, 红色, 在下方</div>
.need-1px-border {
    @include border-1px(red, bottom);
}
@yinxin630 yinxin630 added the css label Nov 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant