Skip to content

Instantly share code, notes, and snippets.

@f8lrebel
Created July 1, 2012 05:45
Show Gist options
  • Save f8lrebel/3027013 to your computer and use it in GitHub Desktop.
Save f8lrebel/3027013 to your computer and use it in GitHub Desktop.
A web page created at CodePen.io
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Multi Gradient SCSS Mixin &middot; CodePen</title>
<style>
html {
height: 100%;
background: -webkit-linear-gradient(top, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0.1) 50%, rgba(255, 255, 255, 0) 50%), -webkit-linear-gradient(left, blue 0%, red 100%);
background: -moz-linear-gradient(top, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0.1) 50%, rgba(255, 255, 255, 0) 50%), -moz-linear-gradient(left, blue 0%, red 100%);
background: -ms-linear-gradient(top, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0.1) 50%, rgba(255, 255, 255, 0) 50%), -ms-linear-gradient(left, blue 0%, red 100%);
background: -o-linear-gradient(top, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0.1) 50%, rgba(255, 255, 255, 0) 50%), -o-linear-gradient(left, blue 0%, red 100%);
background: linear-gradient(top, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0.1) 50%, rgba(255, 255, 255, 0) 50%), linear-gradient(left, blue 0%, red 100%);
}
</style>
<style>
#codepen-footer, #codepen-footer * {
-webkit-box-sizing: border-box !important;
-moz-box-sizing: border-box !important;
box-sizing: border-box !important;
}
#codepen-footer {
display: block !important;
position: fixed !important;
bottom: 0 !important;
left: 0 !important;
width: 100% !important;
padding: 0 10px !important;
margin: 0 !important;
height: 30px !important;
line-height: 30px !important;
font-size: 12px !important;
color: #eeeeee !important;
background-color: #505050 !important;
text-align: left !important;
background: -webkit-linear-gradient(top, #505050, #383838) !important;
background: -moz-linear-gradient(top, #505050, #383838) !important;
background: -ms-linear-gradient(top, #505050, #383838) !important;
background: -o-linear-gradient(top, #505050, #383838) !important;
border-top: 1px solid black !important;
border-bottom: 1px solid black !important;
border-radius: 0 !important;
border-image: none !important;
box-shadow: inset 0 1px 0 #6e6e6e, 0 2px 2px rgba(0, 0, 0, 0.4) !important;
z-index: 300 !important;
font-family: "Lucida Grande", "Lucida Sans Unicode", Tahoma, sans-serif !important;
letter-spacing: 0 !important;
word-spacing: 0 !important;
}
#codepen-footer a {
color: #a7a7a7 !important;
text-decoration: none !important;
}
#codepen-footer a:hover {
color: white !important;
}
</style>
<script>
// Kill alerts, confirmations and prompts
window.alert = function(){};
window.confirm = function(){};
window.prompt = function(){};
window.open = function(){};
window.print = function(){};
</script>
</head>
<body>
<div id="codepen-footer">
<a style="color: #f73535 !important;" href="https://codepen.wufoo.com/forms/m7x3r3/def/field14=" onclick="window.open(this.href, null, 'height=517, width=680, toolbar=0, location=0, status=1, scrollbars=1, resizable=1'); return false">Report Abuse</a>
&nbsp;
<a href="/simurai/pen/4/4">Edit this Pen</a>
</div>
</body>
</html>
@import "compass";
// Multi Gradient SCSS Mixin by @derSchepp
// https://github.com/Schepp/SASS-Mixins/blob/master/sass/style.scss
@function fn-linear-gradient($args) {
$gradient: ();
$pos: nth($args, 1);
@if ($pos != 'top')
and ($pos != 'right')
and ($pos != 'bottom')
and ($pos != 'left')
and ($pos != 'to top')
and ($pos != 'to right')
and ($pos != 'to bottom')
and ($pos != 'to left')
{
$pos: top;
}
@each $g in $args {
@if ($g != 'top')
and ($g != 'right')
and ($g != 'bottom')
and ($g != 'left')
and ($g != 'to top')
and ($g != 'to right')
and ($g != 'to bottom')
and ($g != 'to left')
{
$gradient: append($gradient, $g, comma);
}
}
$collection: (
-webkit-linear-gradient($pos, $gradient),
-moz-linear-gradient($pos, $gradient),
-ms-linear-gradient($pos, $gradient),
-o-linear-gradient($pos, $gradient),
unquote('linear-gradient(#{$pos}, #{$gradient})')
);
@return $collection;
}
@mixin background($args) {
$webkit: ();
$moz: ();
$o: ();
$ms: ();
$official: ();
@each $bg in $args {
$g-webkit: '';
$g-moz: '';
$g-o: '';
$g-ms: '';
$g-official: '';
$isgradient: false;
@each $g in $bg {
$type: type-of($g);
@if($type == list){
$isgradient: true;
}
}
@if ($isgradient != true){
@each $g in $bg {
$g-webkit: $g-webkit + ' ' + $g;
$g-moz: $g-moz + ' ' + $g;
$g-o: $g-o + ' ' + $g;
$g-ms: $g-ms + ' ' + $g;
$g-official: $g-official + ' ' + $g;
}
}
@else{
$g-webkit: $g-webkit + nth(fn-linear-gradient($bg),1);
$g-moz: $g-moz + nth(fn-linear-gradient($bg),2);
$g-o: $g-o + nth(fn-linear-gradient($bg),3);
$g-ms: $g-ms + nth(fn-linear-gradient($bg),4);
$g-official: $g-official + nth(fn-linear-gradient($bg),5);
}
$webkit: append($webkit, unquote($g-webkit), comma);
$moz: append($moz, unquote($g-moz), comma);
$o: append($o, unquote($g-o), comma);
$ms: append($ms, unquote($g-ms), comma);
$official: append($official, unquote($g-official), comma);
}
background:unquote($webkit);
background:unquote($moz);
background:unquote($o);
background:unquote($ms);
background:unquote($official);
}
html {
height: 100%;
@include background((
(top, hsla(0,0%,100%,.5) 0%, hsla(0,0%,100%,.1) 50%, hsla(0,0%,100%,0) 50%),
(left, blue 0%, red 100%)
));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment