Skip to content

Instantly share code, notes, and snippets.

@ashleygwilliams
Last active December 14, 2015 23:39
Show Gist options
  • Save ashleygwilliams/5167348 to your computer and use it in GitHub Desktop.
Save ashleygwilliams/5167348 to your computer and use it in GitHub Desktop.
how to style multiple background images on an element
/* assuming you have images named background1.jpg, background2.jpg in your assets/images folder
set a height so that the image can be seen using 'height'
'background-image' takes url(path/to/image.ext), url(path/to/image.ext) .. as many as you want
MDN entry: https://developer.mozilla.org/en-US/docs/CSS/background-image
'background-position' takes url(path/to/image.ext), url(path/to/image.ext) .. as many as you want
MDN entry: https://developer.mozilla.org/en-US/docs/CSS/background-position */
.container {
height: 250px; /* make this the height of the image */
background-image: url(/assets/images/background1.jpg), url(/assets/images/background2.jpg);
background-position: center bottom, left top; /* you can position each image, separated by a comma */
background-repeat: no-repeat, repeat; /*you can choose to repeat each image too, separated by a comma */
}
@julianchams
Copy link

do i put this in the new custom.css file?

@ashleygwilliams
Copy link
Author

yup. exactly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment