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;
}
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;
}
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 want to have the img in the carousel responsive. The height should be 100vh but the width needs to be as wide as it goes, depending on how big the img is. The overflowing part should be hidden. Now, when the screen gets smaller, the img is resized not to scale. Here's some screen shots
This is fine at full width, desktop version
This is about the witdh of tablets, but there are white space at the bottom which i dont want.
This is the phone version, resized but not to scale. It should also takes up the whole window, but the overflowing width can be hidden.
This is what I have for css:
.carousel,
.carousel-inner {
height: 100vh;
}
.carousel img {
position: absolute;
top: 0;
left: 0;
min-width: 100vw;
height: 100vh;
max-width: none;
}
<div class="carousel-inner" role="listbox">
<div class="item active">
<img class="img-responsive" src="photos/JO2_2978.JPG" alt="xmas_orchestra">
</div>
<div class="item">
<img src="photos/JO2_2875.JPG" alt="...">
</div>
<div class="item">
<img src="photos/IMG_1824.JPG" alt="...">
</div>
<div class="item">
<img src="photos/JO2_2955.JPG" alt="...">
</div>
<div class="item">
<img src="photos/IMG_3913.JPG" alt="...">
</div>
<div class="item">
<img src="photos/JO2_2957.JPG" alt="...">
</div>
</div> <!-- CAROUSEL-INNER -->
There is a better and a very simple way to do this.
Keep all your carousel code within the bootstrap column within a row(Grid system)
And give some class name like .carousel-column in my example and then do two things.
1.Set some height and width as per your wish in your custom css file.
2.And set img-responsive in your code in the mail HTML Page for carousel items.
It worked for me, hope it will work for all.
HTML CODE:
<!-- Carousel to highlight main services-->
<div class="row">
<div class="col-md-9 carousel-column">
<div id="myCarousel" class="carousel slide">
<!-- 1.Carousel Indicators-->
<ol class="carousel-indicators">
<li data-target="#myCarousel" class="active" data-
slideto="0</li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
</ol>
<!-- 2.carousel Items (Picture plus data)-->
<div class="carousel-inner">
<div class="item active">
<img src="images/book2.jpg" class="img-responsive img-cus" >
<div class="container">
<div class="carousel-caption">
<h1>Web Development</h1>
<h3>Let's begin development.It really is about who you are and what you can do</h3>
<p><a class="btn btn-primary btn-large" href="signup.html">Sign Up</a></p>
</div>
</div>
</div>
<div class="item">
<img src="images/book.jpg" class="img-responsive img-cus">
<div class="container">
<div class="carousel-caption">
<h1>Twitter Bootstrap</h1>
<h3>A HTML,CSS,Javascript library for responsive
mobile first web development</h3>
<p><a class="btn btn-primary btn-large"
href="signup.html">Sign Up</a></p>
</div>
</div>
</div>
<div class="item">
<img src="images/coffee.jpg" class="img-responsive img-cus"
>
<div class="container">
<div class="carousel-caption">
<h1>Java Tutorials</h1>
<h3>A powerful secure server side object oriented
programming language</h3>
<p><a class="btn btn-primary btn-large"
href="signup.html">Sign Up</a></p>
</div>
</div>
</div>
</div>
<!-- Now We will create the carousel controls-->
<a href="#myCarousel" class="left carousel-control" data-
slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
</a>
<a href="#myCarousel" class="right carousel-control" data-
slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
</a>
</div>
</div>
</div>
Now do this in CSS file
CSS Styling:
.carousel-column{
height:500px;
width:900px;
margin:0 auto;
}
Try this:
Check Demo here
HTML:
<div class="carousel slide" data-ride="carousel">
<div class="carousel-inner" role="listbox">
<div class="item active" style="background-image:url(http://dentistry.utah.edu/images/slider-banner/roy-hume.jpg); ">
</div>
<div class="item" style="background-image: url(http://dentistry.utah.edu/images/slider-banner/school-dentistry-students.jpg);">
</div>
</div>
<!-- CAROUSEL-INNER -->
</div>
CSS:
.carousel,
.carousel-inner {
height: 100vh;
}
.item {
border: 1px solid grey;
max-height: 100vh;
min-height: 100vh;
max-width: 100vw;
background-size: cover;
background-position: center center;
background-repeat: no-repeat;
}
if you are using img src="...", then use class="img-responsive" and in css width="100%".
it worked like that
<div class="carousel-item activo">
<a href="#" style="display: block; width: 100%; height: 100%;">
<img class="img-fluid d-block w-100" src="01.jpg" alt="Alternate Text" />
</a>
</div>
Need to change img css that please check
.carousel,
.carousel-inner {
height: 100vh;
}
.carousel img {
position: absolute;
top: 0;
left: 0;
min-width: 100%;
height: auto;
max-width: 100%;
}
<div class="carousel-inner" role="listbox">
<div class="item active">
<img class="img-responsive" src="photos/JO2_2978.JPG" alt="xmas_orchestra">
</div>
<div class="item">
<img src="photos/JO2_2875.JPG" alt="...">
</div>
<div class="item">
<img src="photos/IMG_1824.JPG" alt="...">
</div>
<div class="item">
<img src="photos/JO2_2955.JPG" alt="...">
</div>
<div class="item">
<img src="photos/IMG_3913.JPG" alt="...">
</div>
<div class="item">
<img src="photos/JO2_2957.JPG" alt="...">
</div>
</div> <!-- CAROUSEL-INNER -->
.carousel img {
position: absolute;
top: 0;
left: 0;
min-width: 100vw;
height: 100vh;
max-width: none;
object-fit:cover;
object-position:center;
}
Please replace you CSS code.
Please I'd like to make a grand grandchild of a div appear in front of everything in the document, while other children and grandchildren of that div may be subject to change of order.
I tried changing the z-index of everything and it doesn't work.
Please help. The problem is that the captions are behind the circle and i want them to be in front of the circle. This is the result of the code
otekit.com
This is the html, i want the divs with the class "carousel-captions" to be on top of everything, even on top of the img "circle-slider", which is on top of the images inside the divs with the class "carousel-captions".
<div id="carousel1" class="carousel slide main" data-ride="carousel">
<div class="carousel-inner " role="listbox">
<div class="item active">
<div class="carousel-caption">
<h2>Header</h2>
<h3>Some text</h3>
<nav class="color-1 cl-effect-13 cl-effect-20 ">
<span data-hover="Quick Inquiry">Quick Inquiry</span>
</nav>
</div>
<img src="img/slider/bg11.jpg" alt="First slide image" class="center-block slider-img">
</div>
<div class="item">
<div class="carousel-caption">
<h2>Header</h2>
<h3>Some text</h3>
<nav class="color-1 cl-effect-13 cl-effect-20 ">
<span data-hover="Quick Inquiry">Quick Inquiry</span>
</nav>
</div>
<img src="img/slider/bg7.jpg" alt="Second slide image" class="center-block slider-img">
</div>
<div class="item">
<div class="carousel-caption">
<h2>Header</h2>
<h3>Some text</h3>
<nav class="color-1 cl-effect-13 cl-effect-20 ">
<span data-hover="Quick Inquiry">Quick Inquiry</span>
</nav>
</div>
<img src="img/slider/bg22.jpg" alt="Third slide image" class="center-block slider-img">
</div>
</div>
<img id="circle-slider" src="img/slider/circle.png" class="circle-slider img-responsive " alt="Placeholder image">
<a class="left carousel-control" href="#carousel1" role="button" data-slide="prev"><span class="glyphicon glyphicon-chevron-left" style="color: #ed1c3b; opacity: 0.5" aria-hidden="true"></span><span class="sr-only">Previous</span></a><a class="right carousel-control" href="#carousel1" role="button" data-slide="next"><span class="glyphicon glyphicon-chevron-right" style="color: #ed1c3b ; opacity: 0.5" aria-hidden="true"></span><span class="sr-only">Next</span></a>
</div>
</div>
This is the CSS
.carousel {
position: relative;
max-height: 600px;
overflow: hidden;
}
.carousel-inner {
position: relative;
width: 100%;
overflow: hidden;
}
.carousel-inner > .item {
position: relative;
overflow: hidden;
}
.carousel-caption {
position: absolute;
right: 15%;
top: 30vw;
left: 15%;
z-index: 10;
padding-top: 20px;
padding-bottom: 20px;
color: #fff;
text-align: center;
text-shadow: 0 1px 2px rgba(0, 0, 0, .6);
}
.circle-slider{
position: absolute;
bottom: -50%;
left: 50%;
z-index: 15;
width: 60%;
padding-left: 0;
margin-left: -30%;
text-align: center;
list-style: none;
max-width:640px;
opacity: 0.5;
}