很喜歡這個問題和答案。
但是,它只處理面朝下的鋸齒形。
我在這裏添加上/右/左/右方向的SCSS解決方案。
希望這對其他人有用。
@mixin zigzag_downward($color){
background: linear-gradient(45deg, transparent 75%, $color 75%) 0 50%,
linear-gradient(-45deg, transparent 75%, $color 75%) 0 50%;
background-repeat: repeat-x;
background-size:30px 30px, 30px 30px;
}
@mixin zigzag_upward($color){
background: linear-gradient(45deg, $color 25%, transparent 25%) 0 50%,
linear-gradient(-45deg, $color 25%, transparent 25%) 0 50%;
background-repeat: repeat-x;
background-size:30px 30px, 30px 30px;
}
@mixin zigzag_left($color){
background: linear-gradient(45deg, transparent 75%, $color 75%) 0% 0,
linear-gradient(135deg, transparent 75%, $color 75%) 0% 0%;
background-repeat: repeat-y;
background-size:30px 30px, 30px 30px;
}
@mixin zigzag_right($color){
background: linear-gradient(45deg, $color 25%, transparent 25%) 0% 0,
linear-gradient(135deg, $color 25%, transparent 25%) 0% 0%;
background-repeat: repeat-y;
background-size:30px 30px, 30px 30px;
}
這裏是一個codepen例如:http://codepen.io/anon/pen/HjJBF
它的工作原理。謝謝 – tdub2012 2013-03-26 17:15:33