I’m currently in the process of developing a site using Twitter Bootstrap. In the site’s design I have a background-image which sits between the edge of the container and the edge of the body.
Below is my code.
HTML:
<body>
<section>
<div class="container">
<div class="row">
<div class="col-xs-12">
<h1>Lorem Ipsum.</h1>
</div>
</div>
</div>
</section>
</body>
CSS:
section {
background-image: url('example.png');
background-repeat: no-repeat;
background-position: bottom right;
}
The code above simply applies a background-image to the bottom right of my section. I need to ensure that the background-image is at the maximum width it can be without intercepting the container.
Here’s a diagram which might better explain what I’m looking to do.
How do I go about achieving this effect without the use of jQuery/Javascript?
Thanks in advance!
2
Answers
I think this is what you want–
Go full page to see it.
check snippet
CSS only – without the use of jQuery/Javascript
As you may know, the Bootstrap
.container
pixel width changes depending on the screen width. There are 3 separate media queries used for this. You can adjust the background image size in the same way, at each Bootstrap breakpoint..Demo: http://www.codeply.com/go/985dNICmvQ
Note: On the
xs
screen, the container becomes 100% width so your background image will disappear.