I am implement carousel using below code. In this i want two caption as per carousel slide. So i will add one more caption div but it's not working properly.I need one caption for top left corner of the carousel another one bottom of the carousel. I am not aware of css so please help anyone.
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item active">
<img src="la.jpg" alt="Los Angeles" style="width:100%;">
<div class="carousel-caption">
<h3>Los Angeles</h3>
<p>LA is always so much fun!</p>
</div>
</div>
<div class="item">
<img src="chicago.jpg" alt="Chicago" style="width:100%;">
<div class="carousel-caption">
<h3>Chicago</h3>
<p>Thank you, Chicago!</p>
</div>
</div>
</div>
<!-- Left and right controls -->
<a class="left carousel-control" href="#myCarousel" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#myCarousel" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
<span class="sr-only">Next</span>
</a>
I am implement carousel using below code. In this i want two caption as per carousel slide. So i will add one more caption div but it's not working properly.I need one caption for top left corner of the carousel another one bottom of the carousel. I am not aware of css so please help anyone.
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item active">
<img src="la.jpg" alt="Los Angeles" style="width:100%;">
<div class="carousel-caption">
<h3>Los Angeles</h3>
<p>LA is always so much fun!</p>
</div>
</div>
<div class="item">
<img src="chicago.jpg" alt="Chicago" style="width:100%;">
<div class="carousel-caption">
<h3>Chicago</h3>
<p>Thank you, Chicago!</p>
</div>
</div>
</div>
<!-- Left and right controls -->
<a class="left carousel-control" href="#myCarousel" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#myCarousel" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
<span class="sr-only">Next</span>
</a>
Share Improve this question edited Nov 8, 2017 at 10:55 Bourbia Brahim 14.7k4 gold badges43 silver badges54 bronze badges asked Nov 8, 2017 at 10:00 prabapraba 1051 gold badge3 silver badges11 bronze badges 2
- I do not understand what you mean. but you can give example in jsfiddle/devefrontend/21036h5c/8 – saiful Commented Nov 8, 2017 at 10:07
- Thank u for reply.For example i want the text inside the<h3> tag is e on top left of the carousel and the text in <p> tag e on center on the carousel – praba Commented Nov 8, 2017 at 10:16
3 Answers
Reset to default 2I think the below sample will help you ,
Make the caption 100% width and height , and override some properties for poth the h3 and p text (using media queries for different views)
.carousel-caption {
width:100%;
height:100%;
left:0 !important;
}
.carousel-caption h3 {
text-align:left;
margin-left:30px;
}
.carousel-caption p {
margin-top:40%;
}
@media screen and (max-width: 479px) {
.carousel-caption p {
margin-top:20%;
}
}
@media screen and (min-width: 480px) and (max-width: 640px){
.carousel-caption p {
margin-top:30%;
}
}
@media screen and (min-width: 641px) {
.carousel-caption p {
margin-top:40%;
}
}
<script src="https://ajax.googleapis./ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn./bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn./bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item active">
<img src="https://www.w3schools./bootstrap/la.jpg" alt="Los Angeles">
<div class="carousel-caption">
<h3>Los Angeles</h3>
<p>LA is always so much fun!</p>
</div>
</div>
<div class="item">
<img src="https://www.w3schools./bootstrap/chicago.jpg" alt="Chicago">
<div class="carousel-caption">
<h3>Chicago</h3>
<p>Thank you, Chicago!</p>
</div>
</div>
<div class="item">
<img src="https://www.w3schools./bootstrap/ny.jpg" alt="New York">
<div class="carousel-caption">
<h3>New York</h3>
<p>We love the Big Apple!</p>
</div>
</div>
</div>
<!-- Left and right controls -->
<a class="left carousel-control" href="#myCarousel" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#myCarousel" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
<span class="sr-only">Next</span>
</a>
</div>
may be this can help.
for example here > https://jsfiddle/devefrontend/21036h5c/10/
<div class="carousel-caption">
<h3 class="text-right">Los Angeles</h3>
<p class="text-right">LA is always so much fun!</p>
</div>
and css
.carousel-caption {
width:100%;
height:100%;
left:0;
padding: 50px;
}
This part was all i needed and helped.
.carousel-caption {
width:100%;
height:100%;
left:0 !important;
}
.carousel-caption h3 {
text-align:left;
margin-left:30px;
}
.carousel-caption p {
margin-top:40%;
}
@media screen and (max-width: 479px) {
.carousel-caption p {
margin-top:20%;
}
}
@media screen and (min-width: 480px) and (max-width: 640px){
.carousel-caption p {
margin-top:30%;
}
}
@media screen and (min-width: 641px) {
.carousel-caption p {
margin-top:40%;
}
}