I want to place a content DIV
on bootstrap carousel in large and desktop screens. See below image for your understanding.
In mobile and tab screen it should be something like this -
I am not sure how to create this layout using bootstrap 3. Hope somebody may help me out.
This is my current Mark Up:
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css" rel="stylesheet" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<main role="main">
<div id="homepage-feature" class="carousel slide">
<ol class="carousel-indicators">
<li data-target="#homepage-feature" data-slide-to="0" class="active"></li>
<li data-target="#homepage-feature" data-slide-to="1"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item active" style="background: url(img/slider/uniform.jpg) no-repeat center center; background-size: cover;">
<div class="container">
<div class="carousel-caption">
<h3>Providing you the Best</h3>
<h1>Cleaning Companies</h1>
<p>in Bahrain with 10% Discount.</p>
</div>
</div>
</div>
<div class="item" style="background: url(img/slider/uniform.jpg) no-repeat center center; background-size: cover;">
<div class="container">
<div class="carousel-caption">
<h1>Example headline.</h1>
<p class="lead">Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
<a class="btn btn-large btn-primary" href="#">Sign up today</a>
</div>
</div>
</div>
</div>
<!-- /.carousel-inner -->
<!-- Controls -->
<a class="left carousel-control" href="#homepage-feature" data-slide="prev">
‹
</a>
<a class="right carousel-control" href="#homepage-feature" data-slide="next">
›
</a>
</div>
<!-- /#homepage-feature.carousel -->
<div style="width: 300px; height: 500px; background: red;"></div>
</main>
The class="carousel" specifies that this <div> contains a carousel. The.slide class adds a CSS transition and animation effect, which makes the items slide when showing a new item. Omit this class if you do not want this effect. The data-ride="carousel" attribute tells Bootstrap to begin animating the carousel immediately when the page loads.
Carousels require the use of an id (in this case id="myCarousel") for carousel controls to function properly. The class="carousel" specifies that this <div> contains a carousel. The.slide class adds a CSS transition and animation effect, which makes the items slide when showing a new item. Omit this class if you do not want this effect.
The slides are specified in a <div> with class .carousel-inner. The content of each slide is defined in a <div> with class .item.
Bootstrap uses CSS media queries to establish these Responsive Breakpoints. They enable you to control Column behavior at different screen widths. For example: here are 2 columns, each 50% width: The col-sm-6 means use 6 of 12 columns wide (50%), on a typical small device width (greater than or equal to 768 px):
Mirror the size of the .container at every break width and that is the parent called ".red
". Center that .red
absolute positioned element by using left: 50% and then a negative margin 1/2 the width at every break point. Then add the form/div inside that parent and flush it right at the min-width.
CSS
.slide-wrapper {
position: relative
}
.red {
padding-right: 15px;
padding-left: 15px;
margin-right: auto;
margin-left: auto;
}
.red-content {
width: 100%;
height: 300px;
background: red;
color: #fff;
}
@media (min-width: 768px) {
.carousel-caption {
text-align: left;
padding-right: 300px;
}
.red {
width: 750px;
position: absolute;
left: 50%;
top: 0;
bottom: 0;
padding: 20px 0;
margin-left: -375px;
}
.red-content {
width: 300px;
float: right;
height: 100%;
background: red;
color: #fff;
margin-right:15px; /* width of .container gutter */
}
}
@media (min-width: 992px) {
.red {
width: 970px;
margin-left: -485px;
}
}
@media (min-width: 1200px) {
.red {
width: 1170px;
margin-left: -585px;
}
}
/* MISC */
#homepage-feature .item {
overflow: hidden;
height: 400px;
background-color: transparent;
background-size: cover;
}
#homepage-feature > .carousel-control {
width: 30px;
font-size: 40px;
color: #fff;
text-shadow: none;
filter: none;
opacity: 1;
}
#homepage-feature > .carousel-control span {
position: absolute;
top: 50%;
margin-top: -30px;
width: 100%;
text-align: center;
display: block;
}
HTML
<div class="slide-wrapper">
<div id="homepage-feature" class="carousel slide">
<ol class="carousel-indicators">
<li data-target="#homepage-feature" data-slide-to="0" class="active"></li>
<li data-target="#homepage-feature" data-slide-to="1"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item active" style="background-image:url(http://lorempixel.com/1500/600/abstract)">
<div class="carousel-caption">
<h1>Changes to the Grid</h1>
<p>Bootstrap 3 still features a 12-column grid, but many of the CSS class names have completely changed.</p>
<p><a class="btn btn-large btn-primary" href="#">Learn more</a>
</p>
</div>
</div>
<div class="item" style="background-image:url(http://placehold.it/1500x600)">
<div class="carousel-caption">
<h1>Percentage-based sizing</h1>
<p>With "mobile-first" there is now only one percentage-based grid.</p>
<p><a class="btn btn-large btn-primary" href="#">Browse gallery</a>
</p>
</div>
</div>
</div>
<!-- /.carousel-inner -->
<!-- Controls -->
<a class="left carousel-control" href="#homepage-feature" data-slide="prev">
<span class="fa fa-angle-left"></span>
</a>
<a class="right carousel-control" href="#homepage-feature" data-slide="next">
<span class="fa fa-angle-right"></span>
</a>
</div>
<!-- /#homepage-feature.carousel -->
<div class="red">
<div class="red-content">
Content goes here.
</div>
</div>
</div>
<!-- /.container.slide-wrapper -->
Try adding row after container, column style as per you requirement. i have made a generic carousel with a block content which can be place anywhere in the carousel and its fully responsive. please have a look to the demo .
/* Styles go here */
.container {
margin-top: 20px;
}
/* Carousel Styles */
.carousel-indicators .active {
background-color: #2980b9;
}
.carousel-inner img {
width: 100%;
max-height: 460px
}
.carousel-control {
width: 0;
}
.carousel-control.left,
.carousel-control.right {
opacity: 1;
filter: alpha(opacity=100);
background-image: none;
background-repeat: no-repeat;
text-shadow: none;
}
.carousel-control.left span {
padding: 15px;
}
.carousel-control.right span {
padding: 15px;
}
.carousel-control .glyphicon-chevron-left,
.carousel-control .glyphicon-chevron-right,
.carousel-control .icon-prev,
.carousel-control .icon-next {
position: absolute;
top: 45%;
z-index: 5;
display: inline-block;
}
.carousel-control .glyphicon-chevron-left,
.carousel-control .icon-prev {
left: 0;
}
.carousel-control .glyphicon-chevron-right,
.carousel-control .icon-next {
right: 0;
}
.carousel-control.left span,
.carousel-control.right span {
background-color: #000;
}
.carousel-control.left span:hover,
.carousel-control.right span:hover {
opacity: .7;
filter: alpha(opacity=70);
}
/* Carousel Header Styles */
.header-text {
position: absolute;
top: 20%;
left: 1.8%;
right: auto;
width: 96.66666666666666%;
color: #fff;
}
.header-text h2 {
font-size: 40px;
}
.header-text h2 span {
background-color: #2980b9;
}
.header-text h3 span {
background-color: #000;
}
.btn-min-block {
min-width: 170px;
line-height: 26px;
}
.btn-theme {
color: #fff;
background-color: transparent;
border: 2px solid #fff;
margin-right: 15px;
}
.btn-theme:hover {
color: #000;
background-color: #fff;
border-color: #fff;
}
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<body>
<div class="container">
<div class="row">
<!-- Carousel -->
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
<li data-target="#carousel-example-generic" data-slide-to="1"></li>
<li data-target="#carousel-example-generic" data-slide-to="2"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item active">
<img src="http://unsplash.s3.amazonaws.com/batch%209/barcelona-boardwalk.jpg" alt="First slide">
<!-- Static Header -->
<div class="header-text ">
<div class="col-md-12 text-center">
<h2>
<span>Welcome to <strong>demo center</strong></span>
</h2>
<br>
<h3>
<span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span>
</h3>
<br>
</div>
</div><!-- /header-text -->
</div>
<div class="item">
<img src="http://unsplash.s3.amazonaws.com/batch%209/barcelona-boardwalk.jpg" alt="Second slide">
<!-- Static Header -->
<div class="header-text ">
<div class="col-md-12 text-center">
<h2>
<span>Welcome to the world of bootstrap</span>
</h2>
<br>
<h3>
<span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span>
</h3>
<br>
</div>
</div><!-- /header-text -->
</div>
<div class="item">
<img src="http://unsplash.s3.amazonaws.com/batch%209/barcelona-boardwalk.jpg" alt="Third slide">
<!-- Static Header -->
<div class="header-text ">
<div class="col-md-12 text-center">
<h2>
<span>Bootstrap is awesome</span>
</h2>
<br>
<h3>
<span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span>
</h3>
<br>
</div>
</div><!-- /header-text -->
</div>
</div>
<!-- Controls -->
<a class="left carousel-control" href="#carousel-example-generic" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
</a>
<a class="right carousel-control" href="#carousel-example-generic" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
</a>
</div><!-- /carousel -->
</div>
</div>
</body>
Hope this can help you.
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