Last active
January 31, 2019 10:48
-
-
Save erikflowers/6393836 to your computer and use it in GitHub Desktop.
A Less mixin for layering 2 images in a background, and using "background-cover" so the bottom layer is always full size. Good for scrolling fixed backgrounds where you want a screen or other element on top. Here's a 2x2 pixel grid to get you started: http://www.helloerik.com/downloads/grid.png.zip See an example here:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.background-layers(@top, @bottom) { | |
background: url(@top), url(@bottom); | |
background-position: top center, top center; | |
background-attachment: fixed, fixed; | |
background-repeat: repeat, repeat; | |
-webkit-background-size: auto, cover; | |
-moz-background-size: auto, cover; | |
-o-background-size: auto, cover; | |
background-size: auto, cover; | |
} | |
/////// Use it like this. don't forget the single quotes /////// | |
.background-layers('the-top-image.png', 'the-bottom-image.jpg'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example: http://codepen.io/flowerpower/pen/Dxahd