Skip to content

Instantly share code, notes, and snippets.

@Unifex
Created July 7, 2014 08:54
Show Gist options
  • Save Unifex/708b31fc3e9a06671c0e to your computer and use it in GitHub Desktop.
Save Unifex/708b31fc3e9a06671c0e to your computer and use it in GitHub Desktop.
I was wanting to have a Bootstrap/Bootswatch well with a background image instead of dropping the image inside, using css to jam it in in the right shape (rounded corners, etc) and trying to overlay the content in that. This was how I got around it. I suspect there's a better way of doing it (especially something with responsive images) but it's…
<div class="well well-lg" data-well-bg="path/to/image">
Content and stuff.
</div>
jQuery(document).ready(function($) {
$('.well').each(function () {
var data = $(this).data('well-bg');
if (data) {
$(this).css('background-image', 'url(' + data + ')');
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment