I want to include three carousels on my website, which should be full height and should have a parallax effect. I have a code snippet I found some time ago, and it just doesn't work. The parallax effect is not working, and the pictures don't display in full height.
Here is my html code:
<div id="carousel" class="carousel slide carousel-fade" data-ride="carousel" data-interval="6000">
<ol class="carousel-indicators">
<li data-target="#carousel" data-slide-to="0" class="active"></li>
<li data-target="#carousel" data-slide-to="1"></li>
<li data-target="#carousel" data-slide-to="2"></li>
</ol>
<div class="carousel-inner" role="listbox">
<div class="carousel-item active">
<a href="learnmore.html">
<div class="jumbotron paral paralsec">
<h1 class="display-3">Customer orientation</h1>
<p class="lead">Every product is individually customized to your needs</p>
</div>
</a>
</div>
<!-- /.carousel-item -->
<div class="carousel-item">
<a href="lenses.html">
<!-- Second Parallax Section -->
<div class="jumbotron paral paralsec1">
<h1 class="display-3">Customer orientation</h1>
<p class="lead">Your project is at the center of our process chains</p>
</div>
</a>
</div>
<!-- /.carousel-item -->
<div class="carousel-item">
<a href="lmkposition.html">
<!-- Third Parallax Section -->
<div class="jumbotron paral paralsec2">
<h1 class="display-3">Customer orientation</h1>
<p class="lead">All our services are supported by our support team which is always there for you</p>
</div>
</a>
</div>
<!-- /.carousel-item -->
</div>
<!-- /.carousel-inner -->
<a class="carousel-control-prev" href="#carousel" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carousel" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
And here is my CSS code:
.carousel, .slide,
.carousel .carousel-inner,
.carousel .carousel-item,
.carousel .carousel-item img,
.carousel .carousel-control {
border-radius: 0px;
overflow: hidden;
}
/ Header Parallax Element Style/
.paral {
min-height: 900px;
background-attachment: fixed;
background-size: cover;
background-position: 50% 50%;
}
/ Paragraph for Parallax Section /
.paral p {
font-size: 24px;
color:#f5f5f5;
text-align: center;
line-height: 60px;
}
/ Heading for Parallax Section /
.paral h1 {
color: rgba(255, 255, 255, 0.8);
font-size: 60px;
text-align: center;
padding-top: 60px;
line-height: 100px;
}
/ Image for Parallax Section /
.paralsec {
background-image: url(img/customer.jpg);
background-size: 100% !important;
}
.paralsec1 {
background-image: url(img/customer.jpg);
height: 100%;}
.paralsec2 {
background-image: url(img/customer.jpg);
height: 100%;}
.paralsec3 {
background-image: url(img/process.jpg);
}
.paralsec4 {
background-image: url(img/process.jpg);}
.paralsec5 {
background-image: url(img/process.jpg);}
.paralsec6 {
background-image: url(img/quality.jpg);}
.paralsec7 {
background-image: url(img/quality.jpg);}
.paralsec8 {
background-image: url(img/quality.jpg);}
/ Add more images for more sections /
/ Remove Bottom Margin from Jumbotron /
.jumbotron{margin-bottom: 0;}
.values {
text-align: center;
display: block;
margin-left: auto;
margin-right: auto;
}
As you can see, I tried to change some values of the image size, but to no avail. Also, only the first image of my carousel is showing, and the carousel has border even though I tried to erase them.
The CSS is for all three carousels, but I only included the html code of one since they are the same, and the first is the one making the most problems.
Related
I am trying to implement a carousel with Bootstrap, where the images are centered and auto-resized. For example, in the JSFiddle, as you can see the first image (the vertical one) stretches the whole div, while the third image remains at the top. I would like to reproduce the behavior of the Facebook or Twitter carousel, where the images are positioned in the center and resized according to the Div where they are included. Can you help me?
<div id="myCarousel" class="carousel slide">
<!-- Indicators -->
<ul class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active">One</li>
<li data-target="#myCarousel" data-slide-to="1">Two</li>
<li data-target="#myCarousel" data-slide-to="2">Three</li>
</ul>
<!-- Inner -->
<div class="carousel-inner">
<div class="item active">
<img src="https://scontent.ffco3-1.fna.fbcdn.net/v/t1.6435-9/171147625_1208393786271117_8898528403586821491_n.jpg?_nc_cat=111&ccb=1-3&_nc_sid=730e14&_nc_ohc=dDKFCCAYB-oAX_m2xtu&_nc_ht=scontent.ffco3-1.fna&oh=aa418a1e5facad55e6e4781237602778&oe=609A1892"
class="img-responsive" />
<div class="container">
<div class="carousel-caption">
<h1>Photo 1 - Vertical</h1>
<p>Hello!</p>
</div>
</div>
</div>
<div class="item">
<img src="https://scontent.ffco3-1.fna.fbcdn.net/v/t1.6435-9/173646266_1210629629380866_4626783539462302067_n.jpg?_nc_cat=111&ccb=1-3&_nc_sid=730e14&_nc_ohc=QelU_ZVtqAcAX9wHI-l&_nc_ht=scontent.ffco3-1.fna&oh=272c997f1febf514a031aefe9cb712cb&oe=609BBCA2"
class="img-responsive" />
<div class="container">
<div class="carousel-caption">
<h1>Photo 2 - Square</h1>
<p>Hello again!</p>
</div>
</div>
</div>
<div class="item">
<img src="https://scontent.ffco3-1.fna.fbcdn.net/v/t1.6435-9/167432599_1203101340133695_8518788973824059736_n.png?_nc_cat=107&ccb=1-3&_nc_sid=730e14&_nc_ohc=CItpIApuYmgAX_zHj8t&_nc_ht=scontent.ffco3-1.fna&oh=83145492bb38c8c2148df70086382459&oe=609A928F"
class="img-responsive" />
<div class="container">
<div class="carousel-caption">
<h1>Photo 3 - Horizontal</h1>
<p>Hello again and again!</p>
</div>
</div>
</div>
</div>
<!-- Controls -->
<a class="left carousel-control" href="#myCarousel" data-slide="prev">
<span class="icon-prev"></span>
</a>
<a class="right carousel-control" href="#myCarousel" data-slide="next">
<span class="icon-next"></span>
</a>
</div>
CSS
.carousel-indicators > li, .carousel-indicators > li.active {
width: 100px;
height: 25px;
border-radius: 0;
border: solid 1px grey;
background: lightgrey;
text-indent: 0;
}
.carousel-indicators > li.active {
background: white;
}
#myCarousel {
width: 500px;
height: 500px;
}
Add this
$('#myCarousel').owlCarousel({
autoHeight:true
});
Remove Height on CSS
#myCarousel {
width: 400px;
/*height: 400px;*/ /*remove This*/
}
Updated Code
#myCarousel .img-responsive{
margin:0 auto;
max-height:400px;
}
https://jsfiddle.net/lalji1051/qnrzuhm2/
Updeted :- https://jsfiddle.net/lalji1051/xmy46z3L/1/
I'm using the following code to create carousel,
<section id="slider">
<div id="landing-page-carousel" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active carsi">
<img class="landing-pg-image" src="image/1.png" alt="profile">
</div>
<div class="carousel-item carsi">
<img class="landing-pg-image" src="image/2.png" alt="profile">
</div>
<div class="carousel-item carsi">
<img class="landing-pg-image" src="image/3.png" alt="profile">
</div>
<a class="carousel-control-prev" href="#landing-page-carousel" role="button" data-slide="prev">
<span class="carousel-control-prev-icon"></span>
</a>
<a class="carousel-control-next" href="#landing-page-carousel" role="button" data-slide="next">
<span class="carousel-control-next-icon"></span>
</a>
</div>
</div>
</section>
I would like to have the carousel to occupy only 70% of the screen hence I use the following rule,
.carsi{
width: 100%;
height: 70%;
}
Unfortunately, this has no effect on the carousel item. what am I missing?
you can try it.when you use it in this way, you can change the image height proportionally with the carousel item.
.carousel .item {
width:100%;
height: 70%;
}
.item img {
position: absolute;
top: 0;
left: 0;
min-height: 70%;
object-fit: cover;
}
I want to make a photo carousel with a sidebar next to it, kind of like a latest news area with a photo and some text. I have tried making it with the below code but the photos don't overlap each other and instead just become three photos with text.
Here's a link to the code that I based my carousel off. (codepen)
https://codepen.io/_danko/pen/mEjgzp
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<h2 class="text-center">Bootstrap carousel with sidebar</h2>
<h3 class="text-center">This feature does not exist in official Bootstrap</h3>
<div class="container">
<div class="row">
<div class="col-sm-6 col-sm-offset-1">
<div class="carousel slide" data-ride="carousel" id="carousel-example-generic">
<!-- Indicators -->
<ol class="carousel-indicators">
<li class="active" data-slide-to="0" data-target="#carousel-example-generic"></li>
<li data-slide-to="1" data-target="#carousel-example-generic"></li>
<li data-slide-to="2" data-target="#carousel-example-generic"></li>
<li data-slide-to="3" data-target="#carousel-example-generic"></li>
</ol><!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active"><img src="http://via.placeholder.com/600x400/D6BC65/fff?text=First+img"></div>
<div class="item"><img src="http://via.placeholder.com/600x400/008A84/fff?text=Second+img"></div>
<div class="item"><img src="http://via.placeholder.com/600x400/18AAA9/fff?text=Third+img"></div>
<div class="item"><img src="http://via.placeholder.com/600x400/C993A0/fff?text=Fourth+img"></div>
</div><!-- Controls -->
<a class="left carousel-control" data-slide="prev" href="#carousel-example-generic" role="button"><span aria-hidden="true" class="glyphicon glyphicon-chevron-left"></span> <span class="sr-only">Previous</span></a> <a class="right carousel-control" data-slide="next" href="#carousel-example-generic" role="button"><span aria-hidden="true" class="glyphicon glyphicon-chevron-right"></span> <span class="sr-only">Next</span></a>
</div><!-- /.carousel -->
</div><!-- /.col-sm-8 -->
<div class="col-sm-3">
<div class="result">
<p class="active-p" data-slide-to="0" data-target="#carousel-example-generic">01. This text is related to 01. slide</p>
<p data-slide-to="1" data-target="#carousel-example-generic">02. This text is related to 02. slide</p>
<p data-slide-to="2" data-target="#carousel-example-generic">03. This text is related to 03. slide</p>
<p data-slide-to="3" data-target="#carousel-example-generic">04. This text is related to 04. slide</p>
</div>
</div><!-- /.col-sm-8 -->
</div><!-- /.row -->
</div><!-- /.container -->
<div class="author">
Made with ♥ by Danko
</div>
</body>
</html>
Here's the CSS
body {
padding-top: 50px;
}
h3 {
margin-bottom: 50px;
}
.carousel {
min-height: 200px;
margin-bottom: 15px;
}
.carousel-indicators li {
box-shadow: 1px 1px 1px rgba(145, 145, 145, 0.5);
}
p {
padding: 10px;
}
.active-p {
background: #00BCD4;
color: #fff;
}
#media only screen and (min-width: 768px) {
p {
height: 50px;
cursor: pointer;
}
}
#media only screen and (min-width: 992px) {
p {
height: 68px;
}
}
#media only screen and (min-width: 1200px) {
p {
height: 85px;
line-height: 85px;
padding: 0 10px 10px 10px;
}
}
.author {
padding-bottom: 20px;
margin-top: 50px;
text-align: center;
font-size: 14px;
}
However, when put on a proper website the photos don't look like a slider.
Thanks.
the example you use is based on bootstrap and jquery
You have to add :
<link rel='stylesheet prefetch' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css'>
<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js'></script>
<script src='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js'></script>
and the javascript listener (on slid.bs.carousel)
Is anyone could help me with 2 stuffs or one of then on boostrap 4
I wanna do 2 stuffs just like on this IMG:
https://i.imgur.com/Vh1CDe3.png
1- Dark background below Title/Subtitle carousel's
2- I made the pagination more higher, and circular...
But how to show this right inside of circle?
How it's working now:
i.imgur.com/NT48cqX.png
full code:
<style type="text/css">
/* dark background */
#news img {
width: 1300px;
height: 400px;
}
div.carousel-caption {
background:rgba(0,0,0,0.6);
text-shadow:none;
}
div.carousel-caption:hover {
background:rgba(0,0,0,0.9);
}
/* Carousel Title */
h3, .h3 {
font-size:20px;
color: #063;
font-family:'Buenard', serif;
font-weight:bold;
text-transform:inherit;
margin: 0px auto 0px;
text-shadow: 2px 2px 2px #000;
-webkit-text-shadow: 2px 2px 2px #000;
-moz-text-shadow: 2px 2px 2px #000;
text-align: center;
}
/* Pagination */
.carousel-indicators .active {
background: #666;
}
.carousel-indicators :hover {
background-color: #cccccc;
}
.slider-pagi__elem {
padding: 10px 10px;
color: #083F2C;
text-decoration: none;
outline: none;
-webkit-transition: all 0.2s;
-o-transition: all 0.2s;
transition: all 0.2s;
font-family: Arial;
font-size: 16.9px;
position: relative;
bottom: 350px;
left: 480px;
display: inline-block;
vertical-align: top;
width: 2rem;
height: 2rem;
margin: 0 0.5rem;
border-radius: 50%;
border: 2px solid #fff;
cursor: pointer;
}
</style>
<main role="main" class="container_body">
<div class="container" id="news">
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
<!-- indicators dot nov -->
<ol class="carousel-indicators">
<li data-target="#carouselExampleIndicators" data-slide-to="0" class="slider-pagi__elem slider-pagi__elem-2"class="active">1</li>
<li data-target="#carouselExampleIndicators" class="slider-pagi__elem slider-pagi__elem-2" data-slide-to="1">2</li>
<li data-target="#carouselExampleIndicators" class="slider-pagi__elem slider-pagi__elem-2" data-slide-to="2">3</li>
<li data-target="#carouselExampleIndicators" class="slider-pagi__elem slider-pagi__elem-2" data-slide-to="3">4</li>
</ol>
<!-- wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="carousel-item active">
<img class="d-block img-fluid" src="http://placehold.it/900x400" alt="">
<div class="carousel-caption">
<h3>Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</h3>
<p>Bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb. <a class="label label-primary" href="#" target="_blank">Read more:</a></p></p>
</div>
</div>
<div class="carousel-item">
<img class="d-block img-fluid" src="http://placehold.it/900x400" alt="">
<div class="carousel-caption">
<h3>Ccccccccccccccccccccccccccccccccccccccccccccccccccccccccc</h3>
<p>Ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd.: <a class="label label-primary" href="#" target="_blank">Read more:</a></p></p>
</div>
</div>
<div class="carousel-item">
<img class="d-block img-fluid" src="http://placehold.it/900x400" alt="">
<div class="carousel-caption">
<h3>Ccccccccccccccccccccccccccccccccccccccccccccccccccccccccc</h3>
<p>Ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd.: <a class="label label-primary" href="#" target="_blank">Read more:</a></p></p>
</div>
</div>
<div class="carousel-item">
<img class="d-block img-fluid" src="http://placehold.it/900x400" alt="">
<div class="carousel-caption">
<h3>Ccccccccccccccccccccccccccccccccccccccccccccccccccccccccc</h3>
<p>Ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd.: <a class="label label-primary" href="#" target="_blank">Read more:</a></p></p>
</div>
</div>
</div>
<!-- controls or next and prev buttons -->
<a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
</div>
</div>
</main>
The dark background at the bottom should be a div, not image. You can probably do it on the div that has a class of carousel-caption.
EDIT: The get the carousel-caption full width, change .carousel-caption from right: 15% to right: 0% and left: 15% to left: 0%
This will make the text go all the way. Don't forget to include some padding if you need a bit of space from the edge.
I changed the bootstrap carousel default settings from the default chevron-left to menu-left and right. and I added image links. i changed the default height to 270px and change it to container.
My issue is that the arrows float to the top as well as the image links, also when they scroll through the links the links scroll past the arrows when changing.
#carousel-wrap {
background-color: #0b0b0b;
height: 270px;
}
.carousel-control.left, .carousel-control.right{
background: none !important;
filter: progid:none !important;
}
<section id="carousel-wrap">
<div id="carousel1" class="carousel slide container" data-ride="carousel">
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="resources/media/referrals/hub-logo.png" alt="First slide image" class="center-block">
</div>
<div class="item">
<img src="resources/media/referrals/hub-logo.png" alt="Second slide image" class="center-block">
</div>
<div class="item">
<img src="resources/media/referrals/hub-logo.png" alt="Third slide image" class="center-block">
</div>
<div class="item">
<img src="resources/media/referrals/hub-logo.png" alt="Third slide image" class="center-block">
</div>
</div>
<a class="left carousel-control" href="#carousel1" role="button" data-slide="prev"><span class="glyphicon glyphicon-menu-left" aria-hidden="true"></span></a>
<a class="right carousel-control" href="#carousel1" role="button" data-slide="next"><span class="glyphicon glyphicon-menu-right" aria-hidden="true"></span></a>
</div>
</section>
To center arrows vertically you can use line-height property (height of your carousel):
.carousel-control.left,
.carousel-control.right {
background: none !important;
line-height: 270px;
}
For image you can use this technique:
.item {
height: 270px;
}
.item img {
max-height: 100%;
max-width: 100%;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
}