Bring carousel caption on top of the overlay - css

I have this Bootstrap carousel:
HTML:
<div id="carousel-example" class="carousel slide" data-ride="carousel">
<div class="carousel-overlay"></div>
<ol class="carousel-indicators">
<li data-target="#carousel-example" data-slide-to="0" class="active"></li>
<li data-target="#carousel-example" data-slide-to="1"></li>
<li data-target="#carousel-example" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">
<div class="item active">
<img src="http://placekitten.com/1600/600" />
<div class="carousel-caption">
<h3>Meow</h3>
<p>Just Kitten Around</p>
</div>
</div>
<div class="item">
<img src="http://placekitten.com/1600/600" />
<div class="carousel-caption">
<h3>Meow</h3>
<p>Just Kitten Around</p>
</div>
</div>
<div class="item">
<img src="http://placekitten.com/1600/600" />
<div class="carousel-caption">
<h3>Meow</h3>
<p>Just Kitten Around</p>
</div>
</div>
</div>
<a class="left carousel-control" href="#carousel-example" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
</a>
<a class="right carousel-control" href="#carousel-example" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
</a>
</div>
CSS:
.carousel-overlay{
background-color: black;
width: 100%;
opacity: 0.3;
height: 100%;
position: absolute;
z-index: 15;
}
I want the caption and arrow buttons to be on the top the overlay like the carousel indicators. I tried using z-index, but it is not working.
here's a fiddle: http://jsfiddle.net/bM32G/39/

I put the captions and arrow buttons on top of the overlay with z-index in this Fiddle:
http://jsfiddle.net/1xu2fpc8/
I used some !important for simplicity, but it seems to work for me.

To change the color of the content of the carousel you need to refer to, in this case, img. Add the following code to your CSS:
img{
-webkit-filter: sepia(90%) hue-rotate(90deg);
}
Remove or comment out the following line in your HTML:
<div class="carousel-overlay"></div>
You can also look into the following posts:
Tint image using CSS without overlay
CSS image overlay with color and transparency

Since z-index is not working for you..
Try this
.item a img {
opacity: 0.6;
}
.carousel-control {
opacity: 1;
}
.item .carousel-caption {
opacity: 1;
}
FIDDLE

Related

Bug with carousel with Bootstrap 4

I trying make a carousel using bootstrap 4, but I have a problem with arrows and cycles. Using bootstrap 3 it's work perfectly, including the CSS. I have already changed the item class to carousel-item as it sends the documentation, but still I am not having success. I think the problem is very simple, but I can not find it. Could someone help me with this? I would appreciate it and apologize if you infiltrate some stackoverflow rule
My code is:
.carousel-control {
left: -12px;
height: 40px;
width: 40px;
background: none repeat scroll 0 0 #222222;
border: 4px solid #FFFFFF;
border-radius: 23px 23px 23px 23px;
margin-top: 90px;
}
.carousel-control.right {
right: -12px;
}
/* The indicators */
.carousel {
margin-bottom: 0;
padding: 0 40px 30px 40px;
}
.carousel-indicators {
right: 50%;
top: auto;
bottom: -10px;
margin-right: -19px;
margin: 0 auto;
}
/* The colour of the indicators */
.carousel-indicators li {
background: #cecece;
}
.carousel-indicators .active {
background: #428bca;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<div id="Carousel" class="carousel slide">
<ol class="carousel-indicators">
<li data-target="#Carousel" data-slide-to="0" class="active"></li>
<li data-target="#Carousel" data-slide-to="1"></li>
</ol>
<!-- Carousel items -->
<div class="carousel-inner">
<div class="carousel-item active">
<div class="row">
<div class="col-md-3">
<img src="http://placehold.it/250x250" alt="Image" style="max-width:100%;">
</div>
<div class="col-md-3">
<img src="http://placehold.it/250x250" alt="Image" style="max-width:100%;">
</div>
<div class="col-md-3">
<img src="http://placehold.it/250x250" alt="Image" style="max-width:100%;">
</div>
<div class="col-md-3">
<img src="http://placehold.it/250x250" alt="Image" style="max-width:100%;">
</div>
</div>
<!--.row-->
</div>
<!--.carousel-item-->
<div class="carousel-item">
<div class="row">
<div class="col-md-3">
<img src="http://placehold.it/250x250" alt="Image" style="max-width:100%;">
</div>
<div class="col-md-3">
<img src="http://placehold.it/250x250" alt="Image" style="max-width:100%;">
</div>
<div class="col-md-3">
<img src="http://placehold.it/250x250" alt="Image" style="max-width:100%;">
</div>
<div class="col-md-3">
<img src="http://placehold.it/250x250" alt="Image" style="max-width:100%;">
</div>
</div>
<!--.row-->
</div>
<!--.carousel-item-->
</div>
<!--.carousel-inner-->
<a data-slide="prev" href="#Carousel" class="left carousel-control">‹</a>
<a data-slide="next" href="#Carousel" class="right carousel-control">›</a>
</div>
<!--.Carousel-->
What can be this error?
The icons are not showed because you need to add a inside the tags and you can use predefined classes of bs carousel for controlling it:
<a id="previous" class="carousel-control-prev" href="#carrousel" data-slide="prev">
<span class="carousel-control-prev-icon"></span>
</a>
<a id="after" class="carousel-control-next" href="#carrousel" data-slide="next">
<span class="carouse`enter code here`l-control-next-icon"></span>
</a>
In order for bootstrap 4 Carousel to work you have to add jquery, popper and bootstrap js files to your project.
You can see in the link a section named Show components requiring JavaScript, in it your can see Carousel for all slide behaviors, controls, and indicators,
In the code you've added there is no sign for theme and this could be your problem.
You can see in this DEMO that your buttons are working. Take a look at index.html file where I've added this js file scripts (removing theme will reproduce your problem where the buttons are not working).

how to control the size of images in carousel

hi guys i hope you all having a good day just in brief my problem is i have a carousel code made by bootstrap and it's working good but the three images that i had inside the carousel they don't have the same height and i wanna make them full width and i tried to control them by their classes but it didn't work and i tried to gave each image a id but the same thing happened again i didn't work .in honestly i'm seeking from this issue and i don't know how i can deal with it so hopefully y'all can help me with that and thanx again.
You could give a fixed height and overflow: hidden; to .carousel-inner .item class.
So the lines to be added will be
.carousel-inner .item{
height: 300px;
overflow: hidden;
}
On doing this, if the image inside any of the slide is greater than the provided height, then the rest of the image will be hidden. But this may not be the best practice as this may hide important portions of the slide images but if you wish to have uniform height for all the slides in the carousel, then probably this is the best option (2nd best if you consider the option of keeping all images of same dimensions).
here is the css of my file
/*------------------------------------------*/
/*Bootstrap button outline override*/
/*------------------------------------------*/
.btn-outline {
background-color: transparent;
color: inherit;
transition: all .2s;
}
.btn-primary.btn-outline {
color: #428bca;
}
.btn-success.btn-outline {
color: #5cb85c;
}
.btn-info.btn-outline {
color: #5bc0de;
}
.btn-warning.btn-outline {
color: #f0ad4e;
}
.btn-danger.btn-outline {
color: #d9534f;
}
.btn-primary.btn-outline:hover,
.btn-success.btn-outline:hover,
.btn-info.btn-outline:hover,
.btn-warning.btn-outline:hover,
.btn-danger.btn-outline:hover {
color: #fff;
}
/*------------------------------------------*/
/*CSS CUSTOMIZE*/
/*------------------------------------------*/
#info-btn { margin-right: 2%; }
/*------------------------------------------*/
/*carousel*/
/*-----------------------------------------*/
.carousel-inner .item{
height: 638px;
overflow: hidden;
}
<!-- Carousel feature -->
<header id="myCarousel" class="carousel slide">
<!-- 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">
<!-- Set the first background image using inline CSS below. -->
<img src="img/taxi.jpeg" class="fill">
<div class="carousel-caption">
<h2>Caption 1</h2>
</div>
</div>
<div class="item">
<!-- Set the second background image using inline CSS below. -->
<img src="img/ocean.jpeg" class="fill">
<div class="carousel-caption">
<h2>Caption 2</h2>
</div>
</div>
<div class="item">
<!-- Set the third background image using inline CSS below. -->
<img src="img/nyc.jpeg" class="fill">
<div class="carousel-caption">
<h2>Caption 3</h2>
</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>
</header>

How to make bootstrap corousal responsive

I am making bootstrap corousal of full width and height,The height is responsive but the width is not responsive (i.e) when i resize the window the image starts crop according to the width of the viewport,when it reaches to mobile screen size the left part the corousal crops,Below is the Bootstrap and css code,Can anyone help hoe to make image width responsive,Thanks
<header id="myCarousel" class="carousel slide">
<!-- 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">
<!-- Set the first background image using inline CSS below. -->
<div class="fill" style="background-image:url('images/corousal1.jpg');"></div>
<div class="carousel-caption">
<h2>Caption 2</h2>
</div>
</div>
<div class="item">
<!-- Set the second background image using inline CSS below. -->
<div class="fill" style="background-image:url('images/corousal2.jpg');"></div>
<div class="carousel-caption">
<h2>Caption 2</h2>
</div>
</div>
<div class="item">
<!-- Set the third background image using inline CSS below. -->
<div class="fill" style="background-image:url('images/corousal1jpg.jpg');"></div>
<div class="carousel-caption">
<h2>Caption 3</h2>
</div>
</div>
<div class="item">
<!-- Set the third background image using inline CSS below. -->
<div class="fill" style="background-image:url('images/corousal4.jpg');"></div>
<div class="carousel-caption">
<h2>Caption 3</h2>
</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 class="drbatras-logo">
<img src="images/logo.png" alt="logo"/>
</div>
</header>
CSS
html,
body {
height: 100%;
}
.carousel,
.item,
.active {
height: 100%;
position: relative;
}
.carousel-inner {
height: 100%;
}
/* Background images are set within the HTML using inline CSS, not here */
.drbatras-logo{
position: absolute;
top:60px;
right: 170px;
}
.fill {
width: 100%;
height: 100%;
background-position: center;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
-o-background-size: cover;
}
you can use <img> tag and set class="img-responsive"
<img class="img-responsive" src="img_chania.jpg" alt="Chania" width="460" height="345">
you can use this
<div class="fill" id="fill"> </div>
css
#fill{
background:url('images/corousal1.jpg') no-repeat center center;
background-size:100% auto;
}

Bootstrap Carousel Pushing and Pulling Content

I am having some issues with my bootstrap carousel. The images that are currently in it are different sizes and switching between images pushes and pulls content of the page. I want a static height and for the pictures to fill the static height while maintaining aspect ratio. Where have I gone wrong here?
Here is the code from the Carousel:
<header id="main_carousel" class="carousel slide">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#main_carousel" data-slide-to="0" class="active"></li>
<li data-target="#main_carousel" data-slide-to="1" class=""></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<img class="center-block fill" style="background-color:#6A6A6A" src="sample_house_one.jpg" height="inherit" alt="First slide" >
<div class="carousel-caption">
<h3>Next Esate Sale</h3>
<p>July 8th at 9:00 AM</p>
</div>
</div>
<div class="item">
<img class="center-block fill" style="background-color:#6A6A6A" src="Sample_house_two.jpg" height="inherit" alt="Second slide">
<div class="carousel-caption">
<h3>Congrats to the new owners</h3>
<p>Winning bid olny $65,000!!!</p>
</div>
</div>
</div>
<a class="left carousel-control" href="#main_carousel" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#main_carousel" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</header>
Here is the css I'm using with the carousel everything else is standard Bootstrap theme and css:
html,
body {
height: 360px;
}
.carousel {
height: 360px;
}
.carousel-inner > .item img,
.carousel-inner > .item > a > img {
min-height:500px;
max-width: 100%;
}
.item,
.active,
.carousel-inner {
height: 100%;
}
.fill {
width: 100%;
height: 100%;
background-position: center;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
-o-background-size: cover;
}
footer {
margin: 50px 0;
}
Put a max-height: 500px on your img tag so that way it can't shrink or grow with different picture sizes.
Or better, get rid of the min-height and just define height. If your pictures are cropping oddly, you might want to either use a background-image div or crop them to the same size and aspect ratio in an image editing program for the simplest solultion. Since you're using a carousel, cropping the images ahead of time might be the easiest solution.
You could also just allow the div to overflow and hide scroll bars as well, and use flexbox to position the image in the middle with align-items: center to crop the top and bottom evenly.

CSS Fixed position and media queries

Im having a problem with media queries and sidebar div with a fixed position.
Basically when the viewport gets too narrow the main content moves to the left and then sits under the sidebar. I tried to set position to static with the media queries, but then it doesnt work/look the way I want.
Here is the original fiddle: http://jsfiddle.net/ym7sQ/1/
#media (max-width: 991px) {
#sidebar {
position: fixed;
}
}
Here is the one with position static: http://jsfiddle.net/ym7sQ/2/
#media (max-width: 991px) {
#sidebar {
position: static;
}
}
You can see that the sidebar is inside the content, but I want it to be overlaying the top and bottom just as it is above 991px. Below 768 its going to stack which is okay because there is not enought space for sidebar and main content. Could you help me with this please? Thanks.
#media (max-width: 991px)
#sidebar {
position: fixed;
}
I think you should use this.
check it on http://jsfiddle.net/ym7sQ/14/show
Source: http://jsfiddle.net/ym7sQ/14/
Sorry for change a lot. But the main amendment is move the whole #sidebar element out of the container.
HTML:
<div id="top">
<div class="container">
<div class="row">
<div class="col-md-9 col-md-push-3">
<h2>Home</h2>
</div>
</div>
</div>
</div>
<div id="sidebar" class="col-sm-3">
<nav role="navigation">
<ul>
<li class="active">Home</li>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
</nav>
<hr />
<p>info#domain.com
<br />123 456 789</p>
<p>Something something</p>
</div>
<div id="content">
<div class="container">
<div class="row">
<div class="col-sm-3"></div>
<div class="col-sm-9">
<section id="main">
<div id="slider" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#slider" data-slide-to="0" class="active"></li>
<li data-target="#slider" data-slide-to="1"></li>
<li data-target="#slider" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">
<div class="item active">
<img src="http://placekitten.com/1280/720" alt="Slide 1" />
</div>
<div class="item">
<img src="http://placekitten.com/1280/720g" alt="Slide 2" />
</div>
<div class="item">
<img src="http://placekitten.com/1280/720" alt="Slide 3" />
</div>
</div> <a class="left carousel-control" href="#slider" data-slide="prev">
</a>
<a class="right carousel-control" href="#slider" data-slide="next">
</a>
</div>
<div class="main-bottom">
<img src="http://placekitten.com/300/300" alt="Image" /> <a href="contact.html">
<img src="http://placekitten.com/100/100" alt="France" />
</a>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit</p>
</div>
</section>
</div>
</div>
</div>
</div>
<div id="footer">
<div class="container">
<div class="row">
<div class="col-md-9 col-md-push-3">
<p>2013 © All rights reserved.</p>
</div>
</div>
</div>
</div>
The sidebar overlaps with main content is because the element .logo has fixed width(150px) and fixed left/right margin (both 40px), so the the whole width of the .logo element is 230px, which is larger than width of #sidebar element when the page is narrow enough, so #sidebar element is expanded.
Solution:
make the .logo element width dynamic, like:
.logo { width: 80%; margin: 40px auto 70px; }
Then you may have to use <img> tag to show the logo instead of using background.

Resources