carousel caption onhover changes disable carousel controls - html

I want on hover to change the opacity of the carousel-caption (centered)! I tried to achieve this but when this event happens and i have the opacity i want, then the controls of the carousel don't work. any ideas?
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
<li data-target="#carousel-example-generic" data-slide-to="1"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item active">
<img src="media1/1.png">
<div class='carousel-caption'>
<h3><span class='glyphicon glyphicon-asterisk' style='font-size: 50px;'></span><br>GET ... - DEVELOP ... - ENTER ...</h3>
</div>
</div>
<div class="item">
<img src="media1/3.png">
<div class="carousel-caption">
<h3>FLUENCY IN AVAILABLE TOOLS AND LANGUAGES CAN BE BETTER OBTAINED THROUGH COLLABORATIVE, INTENSE, HANDS-ON LEARNING</h3>
</div>
</div>
</div>
<!-- Controls -->
<a class="left carousel-control" href="#carousel-example-generic" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" id='carousL'></span>
</a>
<a class="right carousel-control" href="#carousel-example-generic" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" id='carousR'></span>
</a>
</div>
Here Is My Css:
.carousel-caption {
position:absolute;
width: 100%;
top: 300px;
bottom: auto;
text-align: center;
margin-left: -332px;
padding-left: 0;
}
.carousel-caption:hover{
width: 100%;
top: 300px;
bottom: auto;
text-align: center;
margin-left: -332px;
padding-left: 0;
background: grey;
opacity:0.1;
}

.carousel-caption {
display: none;
}
#carousel-example-generic:hover .carousel-caption {
display: block
width: 100%;
top: 300px;
bottom: auto;
text-align: center;
margin-left: -332px;
padding-left: 0;
background: grey;
opacity:0.1;
}

Related

Image caption not showing on slider

I'm trying to make a slider (imported from bootstrap) with captions on the bottom of the images using HTML and CSS, it does work on two images but not the third one.
Here's the code for the slider and the style.css portion that is used for the slider and caption.
HTML:
<!-------Slider------>
<div id="slider">
<div id="headerSlider" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#headerSlider" data-slide-to="0" class="active"></li>
<li data-target="#headerSlider" data-slide-to="1"></li>
<li data-target="#headerSlider" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">
<div class="carousel-item active">
<img src="img/slider1.jpg" class="d-block w-100" alt="Portfolio">
<div class="carosuel-caption">
<h5>A random caption</h5>
</div>
</div>
<div class="carousel-item">
<img src="img/slider2.jpg" class="d-block w-100" alt="Portfolio">
<div class="carosuel-caption">
<h5>A random caption 1</h5>
</div>
</div>
<div class="carousel-item">
<img src="img/slider3.jpg" class="d-block img-fluid" alt="Portfolio">
<div class="carosuel-caption">
<h5>A random caption 2</h5>
</div>
</div>
<a class="carousel-control-prev" href="#headerSlider" 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="#headerSlider" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
CSS:
#slider
{
margin: 0 auto;
width: 800px;
}
.carosuel-caption
{
top: 100%;
transform: translateY(-50%);
bottom: initial!important;
}
.carosuel-caption h5
{
color: #fff;
font-size: 42px;
}
.carousel-item
{
width: 80%;
height: 50%;
background-color: black;
display: block;
margin-left: auto;
margin-right: auto;
margin-top: 5%;
margin-top: 5%;
}
Picture of the slider:
Working slider image with caption
The slide in which it has no caption
I apologize if I missed something in the post.

Centering images (both vertically and horizontally) in Bootstrap 4 carousel

I am using Bootstrap 4 carousel and I am trying to center an image both vertically and horizontally. The following is my code together with the styling:
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<ul 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>
</ul>
<div class="carousel-inner">
<div class="carousel-item active">
<img src="https://placehold.it/200x200/c0392b/000">
</div>
</div>
<a class="carousel-control-prev" href="#myCarousel" 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="#myCarousel" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
#myCarousel {
height: 100%;
width: 100%;
}
.carousel-indicators {
margin-bottom: 8px;
}
.carousel-indicators>li {
width: 10px;
height: 10px;
border-radius: 100%;
}
.carousel-inner {
height: 100%;
background-color: #213B74;
}
.carousel-item {
text-align: center;
}
.carousel-item img {
display: block;
margin: auto;
}
For now, I have only added one carousel item for testing. The image is being centered horizontally. However, I have tried to set the display attribute for the image to block and its margin to auto but it's still not being centered vertically. Can someone tell me what am I doing wrong, please?
I have tried looking into other questions related to this, but I still didn't find the answer that I'm looking for. In case this question is a duplicate, I would gladly appreciate if you could tell me which answer should I be looking into.
Thanks
Here we go, you will need to add a <div> within the .carousel-item, and within that div your image will be placed. We are taking this mediator div to apply the flex centering effect.
If you try to apply flex classes such as d-flex on .carousel-item the carousel will not work as expected.
here I have added the <div class="parent d-flex justify-content-center"> which places the image within it to exact center of the div. Also you will have to give the div min-height equivalent to the .carousel-item OR some standard height for you carousel, so that it don't collapse if the inner image is smaller in size.
you can get to know more about flex here, also if you would like to try out with some examples go here.
#myCarousel {
height: 100%;
width: 100%;
}
.carousel-indicators {
margin-bottom: 8px;
}
.carousel-indicators>li {
width: 10px;
height: 10px;
border-radius: 100%;
}
.carousel-inner {
height: 100%;
background-color: #213B74;
}
.carousel-item {
text-align: center;
}
.parent {
min-height: 200px;
}
.carousel-item img {
display: block;
margin: auto;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<ul 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>
</ul>
<div class="carousel-inner">
<div class="carousel-item active">
<div class="parent d-flex justify-content-center">
<img src="https://placehold.it/100x200/c0392b/000">
</div>
</div>
<div class="carousel-item">
<div class="parent d-flex justify-content-center">
<img src="https://placehold.it/200x100/c0392b/000">
</div>
</div>
<div class="carousel-item">
<div class="parent d-flex justify-content-center">
<img src="https://placehold.it/150x150/c0392b/000">
</div>
</div>
</div>
<a class="carousel-control-prev" href="#myCarousel" 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="#myCarousel" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
I have fixed your problem using the following code for the css:
#myCarousel {
height: 100vh;
width: 100%;
}
.carousel-indicators {
margin-bottom: 8px;
}
.carousel-indicators>li {
width: 10px;
height: 10px;
border-radius: 100%;
}
.carousel-inner {
height: 100%;
background-color: #213B74;
}
.carousel-item {
height: 100%;
}
.carousel-item img {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%)
}
So first of all, I gave the carousel a height of 100vh to fill the total height of screen (You can give it a fixed height as well). I then made the carousel-item height: 100% in order to make it the full height of carousel and then applied the carousel-item img code as above in order to move the image to the center both horizontally and vertically.
You can achieve this with the align-items-center & align-content-center Bootstrap 4 flex classes. See example below :
.main-wrapper {
width: 100%;
height: 100vh;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="main-wrapper">
<div class="h-100 w-100 d-flex flex-wrap align-items-center align-content-center">
<div class="mx-auto">
Content
</div>
</div>
</div>

Bootsrap Carousel Data-slide Arrows are under slide image

I have a bootstrap carousel i am trying to add buttons/arrows to switch between slides I have assigned the position to be absolute, Its clickable and works but the arrows are under the image what could be the problem check here > link
Here is the code
#myCarousel .carousel-indicators {
position: absolute !important;
}
#media (max-width: 768px) {
/* Make the indicators larger for easier clicking with fingers/thumb on mobile */
#myCarousel .carousel-indicators {
bottom: -20px !important;
position: absolute !important;
}
#myCarousel .carousel-indicators li {
display: inline-block;
margin: 0px 5px;
width: 15px;
height: 15px;
}
#myCarousel .carousel-indicators li.active {
margin: 0px 5px;
width: 20px;
height: 20px;
}
}
<div class="overlay">
<input class="btn btn-default" type="submit" name="submit" value="Order Cleaning" />
</div>
<div id="myCarousel" class="carousel slide" style="width:100%;height:auto">
<!-- 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>
<div class="carousel-inner" style="height:auto">
<div class="item active">
<img src="images/test.png" class="img-responsive">
<div class="container">
<div class="carousel-caption">
</div>
</div>
</div>
<div class="item">
<img src="images/test.png" class="img-responsive">
<div class="container">
<div class="carousel-caption">
</div>
</div>
</div>
<div class="item">
<img src="images/test.png" class="img-responsive">
<div class="container">
<div class="carousel-caption">
</div>
</div>
</div>
<a data-slide="prev" href="#myCarousel" class="left carousel-control"><i class="fa fa-chevron-left"></i></a>
<a data-slide="next" href="#myCarousel" class="right carousel-control"><i class="fa fa-chevron-right"></i></a>
</div>
</div>
You made mistake in your css
Check your 768px css you were give botton: -20px !important, change
This
#myCarousel .carousel-indicators {
bottom: -20px !important;
position:absolute !important;
}
To
#myCarousel .carousel-indicators {
bottom: 0px !important;
position:absolute !important;
}
EDIT
i see you are using icomoon css
So have to change this html
<a data-slide="prev" href="#myCarousel" class="left carousel-control">
<i class="fa fa-chevron-left"></i>
</a>
<a data-slide="next" href="#myCarousel" class="right carousel-control">
<i class="fa fa-chevron-right"></i>
</a>
TO
<a data-slide="prev" href="#myCarousel" class="left carousel-control">
<i class="icon-arrow-left"></i>
</a>
<a data-slide="prev" href="#myCarousel" class="left carousel-control">
<i class="icon-arrow-right"></i>
</a>
And give additional css
CSS
.left.carousel-control i {
position: absolute;
left: 10px;
top: 45%;
font-size: 35px;
}
.right.carousel-control i {
position: absolute;
right: 10px;
top: 45%;
font-size: 35px;
}
Output

Bootstrap carousel with fixed height: center image horizontally or vertically based on image dimensions

I have a bootstrap carousel with a fixed height. Here is the CSS:
.carousel-custom .carousel-outer {
position: relative;
}
#media(min-width: 992px){
.carousel-custom {
margin-top: 20px;
.carousel-inner {
height: auto;
.item {
height:500px;
line-height:300px;
}
}
}
}
#media(max-width: 991px){
.carousel-custom {
margin-top: 20px;
.carousel-inner {
height: auto;
.item {
height:300px;
line-height:300px;
text-align:center;
}
}
}
}
And here is my markup:
<div id="carousel-custom-1188" class="carousel slide carousel-custom" data-ride="carousel">
<div class="carousel-outer">
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<img class="img-responsive" src="http://res.cloudinary.com/dltbqhact/image/upload/v1459261752/w8edcuvz1yl3uc4g4o34.jpg" alt="Jinallzupvfazqqr67nd">
<div class="carousel-caption"></div>
</div>
<div class="item">
<img class="img-responsive" src="http://res.cloudinary.com/dltbqhact/image/upload/v1459175684/w4ueot8o49dh2fyulv0x.jpg" alt="K1yov5hpur8mgsb9r15p">
<div class="carousel-caption"></div>
</div>
<div class="item">
<img class="img-responsive" src="http://res.cloudinary.com/dltbqhact/image/upload/v1459178926/fwlmuroj2wlz7czrsha0.jpg" alt="Lqfandhmutdkppjrl932">
<div class="carousel-caption"></div>
</div>
</div>
<!-- Controls -->
<a class="left carousel-control" href="#carousel-custom-1188" 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="#carousel-custom-1188" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
<!-- Indicators -->
<ol class="carousel-indicators mCustomScrollbar">
<li data-target="#carousel-custom-1188" data-slide-to="0" class="active">
<img style="height:50px; width: 50px;" class="img-responsive" src="http://res.cloudinary.com/dltbqhact/image/upload/v1459268139/jinallzupvfazqqr67nd.png" alt="Jinallzupvfazqqr67nd">
</li>
<li data-target="#carousel-custom-1188" data-slide-to="1" class="">
<img style="height:50px; width: 50px;" class="img-responsive" src="http://res.cloudinary.com/dltbqhact/image/upload/v1459268146/k1yov5hpur8mgsb9r15p.png" alt="K1yov5hpur8mgsb9r15p">
</li>
<li data-target="#carousel-custom-1188" data-slide-to="2" class="">
<img style="height:50px; width: 50px;" class="img-responsive" src="http://res.cloudinary.com/dltbqhact/image/upload/v1459268157/lqfandhmutdkppjrl932.png" alt="Lqfandhmutdkppjrl932">
</li>
</ol>
</div>
</div>
The issue is that I have images that are very wide, others very narrow and high, and others with a good ration height/width in the same carousel.
I'd like to have the wide images centered vertically (with a width of a 100%), high images centered horizontally (with a height of 100%) and "normal" images (with a decent ratio height/width) filling all the carousel.
Here is what I'm trying to do (first image is an example with a very wide image, second image with a very high one, and last one has a "decent" ratio).
How could I achieve this ? I've tried Make Bootstrap's Carousel both center AND responsive? and other tricks found on Google but none did this.
Since the .item elements are relative positioned you could just position the img elements absolutely. Giving the .item elements a fixed height, will help to vertically and horizontally align the images inside.
I'm sure there are lots of different ways to do this, here is one example. Hope it helps.
#import url('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css');
body {
background-color: black;
}
.carousel-inner > .item {
height: 100vh;
}
.carousel-inner > .item > img {
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
max-height: 800px;
width: auto;
}
.carousel-control.left,
.carousel-control.right {
background-image: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<div class="container">
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
<!-- indicators -->
<ol class="carousel-indicators">
<li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
<li data-target="#carousel-example-generic" data-slide-to="1"></li>
<li data-target="#carousel-example-generic" data-slide-to="2"></li>
</ol>
<!-- inner -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="http://placehold.it/1200x600/2c3e50/000" alt="">
</div>
<div class="item">
<img src="http://placehold.it/600x1200/d35400/000" alt="">
</div>
<div class="item">
<img src="http://placehold.it/600x600/c0392b/000" alt="">
</div>
</div>
<!-- controls -->
<a class="left carousel-control" href="#carousel-example-generic" 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="#carousel-example-generic" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
Alright, I've been fiddling around for a while now. Ended up with the result below. Hope it helps and answers your question (at least for a small part).
<head>
<title>Bootstrap Carousel</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<style>
html,
body {
height: 100%;
}
.carousel,
.item,
.active {
height: 100%;
}
.carousel-inner {
height: 100%;
}
/* Background images are set within the HTML using inline CSS, not here */
.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;
}
.tester {
height: 100%;
}
</style>
</head>
<body>
<div class="tester">
<!-- Full Page Image Background Carousel Header -->
<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('http://res.cloudinary.com/dltbqhact/image/upload/v1459268139/jinallzupvfazqqr67nd.png');"></div>
<div class="carousel-caption">
<h2>Caption 1</h2>
</div>
</div>
<div class="item">
<!-- Set the second background image using inline CSS below. -->
<div class="fill" style="background-image:url('http://res.cloudinary.com/dltbqhact/image/upload/v1459268146/k1yov5hpur8mgsb9r15p.png');"></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('http://res.cloudinary.com/dltbqhact/image/upload/v1459268157/lqfandhmutdkppjrl932.png');"></div>
<div class="carousel-caption">
<h2>Caption 3</h2>
</div>
</div>
</div>
<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>
<script>
$('.carousel').carousel({
interval: 5000 //changes the speed
})
</script>
</div>
</body>
Again, hope it helps!
simply use image on absolute if your slider height is fixed
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
<li data-target="#carousel-example-generic" data-slide-to="1"></li>
<li data-target="#carousel-example-generic" data-slide-to="2"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<div class="middle">
<img src="http://placehold.it/1920x500">
</div>
</div>
<div class="item">
<div class="middle">
<img src="http://placehold.it/1920x300">
</div>
</div>
<div class="item">
<div class="middle">
<img src="http://placehold.it/600x900">
</div>
</div>
</div>
<!-- Controls -->
<a class="left carousel-control" href="#carousel-example-generic" 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="#carousel-example-generic" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
css
.carousel {
width: 500px; /*test width*/
height: 300px; /*what ever height */
}
.middle {
position: relative;
height: 300px; /*what ever height */
}
.middle img {
max-width: 100%;
max-height: 100%; /*what ever height */
margin: auto;
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
}
see fiddle
If you try to achieve this in bootstrap carousel, you will end up with black bars in top and bottom...I was stuck with similar problem and ended up using "flickity" js library..it works lot better than tryig to achieve this on something not meant for this....

How to set carousel in the middle of the screen?

I have this in carousel.css file (bootstrap), I set width of the image to 900px, but I want to have this image in the middle of the screen, how to do it? (I tried to edit left variable, but nothing happened, and I want it not fixed, something like <center></center>)
.carousel-inner > .item > img {
position: absolute;
top: 0;
left: 0;
width: 900px;
height: 500px;
}
index.html:
<div id="myCarousel" class="carousel slide" data-ride="carousel" >
<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>
<div class="carousel-inner">
<div class="item active">
<img data-src="holder.js/900x500/auto/#777:#7a7a7a/text:blabla" alt="First slide">
<div class="container">
<div class="carousel-caption">
<h1>aaa</h1>
<p>xxxx</p>
</div>
</div>
</div>
</div>
<a class="left carousel-control" href="#myCarousel" data-slide="prev"><span class="glyphicon glyphicon-chevron-left"></span></a>
<a class="right carousel-control" href="#myCarousel" data-slide="next"><span class="glyphicon glyphicon-chevron-right"></span></a>
</div>
If you just want to center horizontally you can do margin: 0 auto; and get rid of your absolute positioning. If you want to center vertically and horizontally you can do
.carousel-inner{
position: relative;
}
.carousel-inner > .item > img {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
width: 900px;
height: 500px;
}
You can set the #myCarousel div's width to 900px too and margin: 0 auto.