I've got a large div where users can swap out the backgrounds with either patterns or their own images. For small background images that are not sized to cover the entire div, I want the images to repeat horizontally and vertically and not stretch to over 100% of their natural width. For larger images that would cover more than the width of the div, I want to limit those to not stretch beyond 100% of the div width so that the entire width of the image is visible.
Is there any way to accomplish this without using JavaScript?
Plunker here:http://plnkr.co/edit/Pkx49a3Ku34YsupqLCRs?p=preview
#background1
should repeat as it currently is
#background2
should not stretch beyond 100% of the container width
To clarify, I'm looking for a solution that doesn't involve JS and will work for BOTH cases (can't just add styling to a specific element)