SCSS Reverse direction

By Mike Street


Web


CSS

There may be a point in your CSS coding that you want to know the opposite of a direction (e.g. up, down). This function allows you to pass it a direction and get the opposite back!​

Fairly basic principle. If it can’t find the opposite it just returns what it was passed. Verbose function name so it don’t conflict with anything else.

@function reverseDirection($direction) {
    $output: $direction;
    @if $direction == right {
        $output: left;
    } @else if $direction == left {
        $output: right;
    } @else if $direction == up {
        $output: down;
    } @else if $direction == down {
        $output: up;
    } @else {
        @debug 'Could not reverse #{$direction}';
    }
    @return $output;
}
稿源:Mike Street (源链) | 关于 | 阅读提示

本站遵循[CC BY-NC-SA 4.0]。如您有版权、意见投诉等问题,请通过eMail联系我们处理。
酷辣虫 » 综合编程 » SCSS Reverse direction

喜欢 (0)or分享给?

专业 x 专注 x 聚合 x 分享 CC BY-NC-SA 4.0

使用声明 | 英豪名录
切换注册

登录

忘记密码 ?

您也可以使用第三方帐号快捷登录

Q Q 登 录
微 博 登 录
切换登录

注册