Skip to content

Instantly share code, notes, and snippets.

@adamsir
Created September 18, 2014 09:21
Show Gist options
  • Save adamsir/46e2a0dede5b5323e3b5 to your computer and use it in GitHub Desktop.
Save adamsir/46e2a0dede5b5323e3b5 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// libsass (v2.0.0)
// ----
/* =Mixin for dynamic backgrounds
=Author: @Donuteeze w/Adam Šír
============================== */
@mixin content-section-background($class, $nth-child:'all', $steps: 4 ) {
@for $i from 1 through $steps {
@if($nth-child == 'all') {
&.#{$class}-#{$i} {
background: url('../i/#{$class}-#{$i}.jpg') top center;
background-repeat: no-repeat;
background-size: cover;
}
}
@if($nth-child == 'even') {
@if($i % 2 ==0) {
&.#{$class}-#{$i} {
background: url('../i/#{$class}-#{$i}.jpg') top center;
background-repeat: no-repeat;
background-size: cover;
}
}
}
@if($nth-child == 'odd') {
@if($i % 2 != 0) {
&.#{$class}-#{$i} {
background: url('../i/#{$class}-#{$i}.jpg') top center;
background-repeat: no-repeat;
background-size: cover;
}
}
}
}
}
// Examples
@include content-section-background('homepage', 'odd');
@include content-section-background('content-section-learn-item', 'even');
@include content-section-background('footer-item');
/* =Mixin for dynamic backgrounds
=Author: @Donuteeze w/Adam Šír
============================== */
.homepage-1 {
background: url('../i/homepage-1.jpg') top center;
background-repeat: no-repeat;
background-size: cover; }
.homepage-3 {
background: url('../i/homepage-3.jpg') top center;
background-repeat: no-repeat;
background-size: cover; }
.content-section-learn-item-2 {
background: url('../i/content-section-learn-item-2.jpg') top center;
background-repeat: no-repeat;
background-size: cover; }
.content-section-learn-item-4 {
background: url('../i/content-section-learn-item-4.jpg') top center;
background-repeat: no-repeat;
background-size: cover; }
.footer-item-1 {
background: url('../i/footer-item-1.jpg') top center;
background-repeat: no-repeat;
background-size: cover; }
.footer-item-2 {
background: url('../i/footer-item-2.jpg') top center;
background-repeat: no-repeat;
background-size: cover; }
.footer-item-3 {
background: url('../i/footer-item-3.jpg') top center;
background-repeat: no-repeat;
background-size: cover; }
.footer-item-4 {
background: url('../i/footer-item-4.jpg') top center;
background-repeat: no-repeat;
background-size: cover; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment