I have the following markup:
<div class="banner-wrapper">
<div class="banner-image" style="background-image: url(...);"></div>
<div class="container">
<div class="row">
<div class="col-xs-12">
SOME ARBITRARILY LONG TEXT
</div>
</div>
</div>
</div>
And the corresponding SCSS:
.banner-wrapper {
width: 100%;
position: relative;
.banner-image {
background-position: center;
background-size: cover;
}
.container {
text-align: center;
position: absolute;
bottom: 0;
}
}
What I want is the text to appear on top of the image conserving the responsive margins that come with a container. The image is full width (like it was inside a container-fluid).
The problem is that setting position: absolute
on the container seems to break it. Is there a better way to achieve this?
JsFiddle: https://jsfiddle.net/DTcHh/8801/
You just need an absolute wrapper for your container, instead of making that container absolute, keeping bootstrap clean.
i've modified your jsfiddle to below.. kindly accept if this is what you were looking for, thanks.
/* Latest compiled and minified CSS included as External Resource*/
/* Optional theme */
@import url('//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css');
.banner-wrapper {
width: 100%;
position: relative;
}
.banner-image {
width: 100%;
height: 450px;
background-color: gray;
}
.absolute-wrapper{
position: absolute;
width:100%;
top:50%;
}
.container {
text-align: center;
}
<div class="banner-wrapper">
<div class="banner-image"></div>
<div class ="absolute-wrapper">
<div class="container">
<div class="row">
<div class="col-xs-12">
SOME VERY LONG TEXT IN AN ABSOLUTE DIV
</div>
</div>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-xs-12">
SOME ARBITRARILY LONG TEXT WITH CORRECT MARGINS
</div>
</div>
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With