how to control the size of images in carousel - css

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>

Related

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;
}

Bring carousel caption on top of the overlay

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

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.

How can I make an div span the entire width of my screen

Im making a little project and I just cant seem to get my css right... I need my header div(I used a regular div instead of an actual header because I wanted everything in the body). I want the blue header span my entire screen, but I just dont know how. I tried somethings with margin and padding but thats it.
Also I tried getting those buttons to the bottom of the Div, but just cant seem to get it right...
SCREENSHOT: http://prntscr.com/9slfw2
Description: See my website here
CSS:
body {
margin: 0px;
padding: 0px;
}
ul {
list-style-type: none;
}
.page-header{
background-color: #0094ff;
margin-top: 0px;
display: block
}
.panel, .list-group-item, .btn {
border-color: #0094ff;
}
#btnRegister {
margin-right: 10px;
vertical-align: bottom;
}
.input-group-addon {
min-width: 40px;
}
legend.scheduler-border {
width:inherit;
padding:0 10px;
border-bottom:none;
}
HTML:
<!-- Carousel -->
<div id="homeCarousel" class="carousel slide">
<!-- Menu -->
<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>
<!-- Items -->
<div class="carousel-inner">
<!-- Item 1 -->
<div class="item active">
<img class="c_img" src="~/Images/chevy.jpg" />
<div class="container">
<div class="carousel-caption">
<h1>Contact</h1>
<p style="background-color:#428bca;">Om gemakkelijk met Rent-a-Car contact op te nemen kunt u ook bellen!</p>
<p style="background-color:#428bca;">Tel: 0534891034, Adres: Vuurnatieweg 69420</p>
<p>
<a class="btn btn-lg btn-primary" href="~/Home/Contact" >Klik hier voor meer contact informatie!</a>
</p>
</div>
</div>
</div>
<!-- Item 2 -->
<div class="item">
<img class="c_img" src="~/Images/42-RT-76.jpg" />
<div class="container">
<div class="carousel-caption">
<h1>Changes to the Grid</h1>
<p style="background-color:#428bca;">Bootstrap 3 still features a 12-column grid, but many of the CSS class names have completely changed.</p>
<p style="background-color:#428bca;"><a class="btn btn-large btn-primary" href="#">Learn more</a></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 id="carouselButtons">
<button id="playButton" type="button" class="btn btn-default btn-xs">
<span class="glyphicon glyphicon-play"></span>
</button>
<button id="pauseButton" type="button" class="btn btn-default btn-xs">
<span class="glyphicon glyphicon-pause"></span>
</button>
</div>
</div>
<script type="text/javascript">
$(function () {
$('#homeCarousel').carousel({
interval:5000,
pause: "false"
});
$('#playButton').click(function () {
$('#homeCarousel').carousel('cycle');
});
$('#pauseButton').click(function () {
$('#homeCarousel').carousel('pause');
});
});
</script>
EDIT: HTML code and .. I am using Bootstrap, just so you know
The issue is that you're using Bootstrap, as indicated by the classes in your HTML and your clarifying edit. Bootstrap adds its own styling (obviously).
In particular, the .container class has padding, margins, and a fixed width that will prevent your layout from spanning the full screen. If you're doing things correctly, your .row <div> tag is in a container.
You have two options to fix this:
Use .container-fluid instead of .container**
This is the preferred option.
Override the default .container CSS rules
To override it, add rules for .container, like so:
.container {
padding-left: 0px;
padding-right: 0px;
margin-right: 0px;
margin-left: 0px;
width: 100%;
}
Here's a sample with Bootstrap's default CSS and one with the .container tweaks above.
Note: if you only want to override the one .container, just give it its own class or id and use an appropriate selector instead of .container in your CSS.
If you're using bootstrap, you can use .container-fluid instead of .container to get a full-width container.
Also, you seem to have mixed head (not in body) with header (in body).
More on the header tag: https://developer.mozilla.org/en/docs/Web/HTML/Element/header
Your code does span
Have a look here Demo

Image positioned over container div limit

For better understanding I'm updating the entire question.
I'm using bootstrap 3 and the carousel component, however, one of the pages of the carousel contains an image that needs to be positioned in the bottom of the section tag without resizing the container.
Here is the code I'm using:
<section id="header-slider" class="section carousel slide" data-ride="carousel" style="padding-bottom: 0;">
<!-- Start Slider Navigation -->
<ol class="carousel-indicators">
<li class="active" data-slide-to="0" data-target="#header-slider"></li>
<li data-slide-to="1" data-target="#header-slider" class=""></li>
</ol>
<!-- End Slider Navigation -->
<div class="carousel-inner">
<div class="item row active">
<div class="col-xs-5 hidden-sm">
<img src="..." style="margin-top: -40px">
</div>
<div class="col-xs-7">
<h1>...</h1>
<p>...</p>
</div>
</div>
<div class="item row">
<div class="col-xs-8">
<h1>...</h1>
<p>...</p>
</div>
</div>
</div>
</section>
Here is a running page with the problem: www.remotepark.com.br
You may see that after transitioning to the second page on carousel component, it is resized.
How can I fix this keeping the height of the pages equal (actually all pages need to have the same height as page 2)?
Not sure if I completely understood..
but maybe give this a try and see if it accomplishes what you're aiming for.
<div style="width: 400px; height: 250px; position: relative;">
<div style="width: 400px; height: 150px">
<img src="..." style="width: 200px; height: 200px; position: absolute; bottom: 0;" />
</div>
</div>
Try changing your style.css from
.carousel .item {
padding-top: 50px;
height: 300px;
}
to:
.carousel .item {
height: 290px; /* the image height */
}
also remove:
style="margin-top: -40px" from the image in the first carousel item

Resources