【发布时间】:2015-04-02 18:55:27
【问题描述】:
我一直在寻找一种仅使用 CSS 的方式来制作 zig zag 边框,过了一会儿我在 codepen 上找到了这个例子,这里是 http://codepen.io/anon/pen/artDy,但它不包括透明度,所以我决定修改它,我得出的这段代码在该在线资源上完美运行(您可以尝试将其粘贴到链接中,并查看我的自定义):
@mixin border-top-serrated($size, $color-outer) {
& {
position: relative;
padding-top: $size;
}
&:before {
top: 0px;
@include background(linear-gradient(-135deg, $color-outer $size / 2, transparent 0), linear-gradient(135deg, $color-outer $size / 2, transparent 0));
@include border-serrated-helper($size, $color-outer);
}}
@mixin border-bottom-serrated($size, $color-outer) {
& {
position: relative;
padding-bottom: $size;
}
&:after {
bottom: -30px;
background-position: right top;
@include background(linear-gradient(4545deg, $color-outer $size / 2, transparent 0), linear-gradient(-4545deg, $color-outer $size / 2, transparent 0));
@include border-serrated-helper($size, $color-outer);
}}
@mixin border-serrated-helper($size, $color-outer) {
content: " ";
display: block;
position: absolute;
left: 0px;
width: 100%;
height: $size;
background-repeat: repeat-x;
background-size: $size $size;}
.serrated {
background: #dddccf;
color: #aca8a1;
text-align: center;
@include border-bottom-serrated(32px, rgba(255, 0, 0, 0.3) );}
但是当我在一个普通的 SCSS 文件上使用它时,我的 SCSS 转换器告诉我有一个未定义的 mixin background。现在,我看到,事实上,mixin background 没有在任何地方定义。
我怎样才能让它工作?
【问题讨论】: