I have a carousel of text that need to be aligned, also not sure how to make its bullets active.
By clicking on the demo link below you would see the bullet points are not in the middle of the page and based on size of the name and the text the distance between name and bullet get changed.
I need all of them (text,name,bullets) be in the middle of the page for any screen size.
.carousel-content {
color: black;
display: flex;
align-items: center;
}
.name {
color: black;
display: block;
font-size: 20px;
text-align: center;
}
.mytext {
border-left: medium none;
font-size: 24px;
font-weight: 200;
line-height: 1.3em;
margin-bottom: 10px;
padding: 0 !important;
text-align: center;
}
.bullets li {
background: none repeat scroll 0 0 #ccc;
border: medium none;
cursor: pointer;
display: inline-block;
float: none;
height: 10px;
width: 10px;
}
.bullets li:last-child {
margin-right: 0;
}
.bullets li {
border-radius: 1000px;
}
<div id="carousel-example" class="carousel slide" data-ride="carousel">
<!-- Wrapper for slides -->
<div class="row">
<div class="col-xs-offset-3 col-xs-6">
<div class="carousel-inner">
<div class="item active">
<div class="carousel-content">
<div>
<h3>#1</h3>
<p>This is a twitter bootstrap carousel that only uses text. There are no images in the carousel slides.</p>
</div>
</div>
</div>
<div class="item">
<div class="carousel-content">
<div>
<h3>#2</h3>
<p>This is another much longer item. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Animi, sint fuga temporibus nam saepe delectus expedita vitae magnam necessitatibus dolores tempore consequatur dicta cumque repellendus eligendi ducimus placeat! Sapiente, ducimus, voluptas, mollitia voluptatibus nemo explicabo sit blanditiis laborum dolore illum fuga veniam quae expedita libero accusamus quas harum ex numquam necessitatibus provident deleniti tenetur iusto officiis recusandae corporis culpa quaerat?</p>
</div>
</div>
</div>
<div class="item">
<div class="carousel-content">
<div>
<h3>#3</h3>
<p>This is the third item.</p>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Controls --> <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>
setCarouselHeight('#carousel-example');
function setCarouselHeight(id) {
var slideHeight = [];
$(id + ' .item').each(function() {
// add all slide heights to an array
slideHeight.push($(this).height());
});
// find the tallest item
max = Math.max.apply(null, slideHeight);
// set the slide's height
$(id + ' .carousel-content').each(function() {
$(this).css('height', max + 'px');
});
}
UPDATE
I changed the code of bullets to the following and it causes them to move a bit to to the top. (in the middle of the text)
<div class="col-xs-offset-4 col-xs-8">
<ol class="bullets carousel-indicators">
<li class="active" data-target="#carousel-example" data-slide-to="1"></li>
<li class="" data-target="#carousel-example" data-slide-to="2"></li>
<li class="" data-target="#carousel-example" data-slide-to="3"></li>
</ol>
8
Answers
Try this rules in
.bullets
element:Change the wrapper’s offset to 2:
Also, reset margin and padding from
ol
:Check the DEMO
To make the bullet working you can just give one attribute to each list item as
data-target="#myCarousexxx"
. It will automatically work no need of script to write.Add one class to bullets list UL that
carousel-indicators
.Your
data-slide-number
should be asdata-slide-to
Dats it buddy. No need of css it will automatically will align. Study the bootstarp.
Demo
Either offset your bullets, or move your content areas to span the whole width
CSS
So to overcome those use the below CSS Code i have attacked some Selectors so it wont affect your bottstrap.css
DEMO
Your main problem is that your markup is a bit different than the markup required by Bootstrap for its carousel. You therefore need to change the following:
carousel-indicators
ol
should be nested right under the.carousel
and not in thecarousel-inner
. This will not only solve your alignment issue for the indicators, but will also cause them to be displayed as expected (ie. the “active” indicator will be highlighted).text-align: center;
. In fact thecol-xs-offset-4 col-xs-8
is what causes your text to be misaligned since it takes up 8 columns but leaving 4 columns blank at the left side of the page.The updated markup therefore becomes as follows:
You will also notice that with this markup you will need minimal extra CSS since most of what you need to do will be taken care of by the Bootstrap CSS.
See the updated demo.
As a side note, according to Bootstrap you should be using the
carousel-caption
class for any text you need to insert in the carousel (what is now incarousel-content
), since Bootstrap assumes that your carousel will also have an image for each item. Since however this is not the case for you I have kept thecarousel-content
class instead since thecarousel-caption
is not correctly aligned/displayed without a corresponding image.First of all. Change your bullets to this
Javascript counts from 0
I’ve added some css for the bullets and de slider container. And I moved the bullets to the back of the parent div.. It seems to work
http://jsfiddle.net/gfcnqzy2/17/
Just a few changes to make it all work:
1) Zero indexing. Start
data-slide-to
from 0, not from 1:2) Slides padding. Add some extra padding to slides for bullets:
3) Bullets offset. Reduce bottom bullets offset to look it better:
Demo
Use custom made carousel, here is an exmpale of something i created quickly.
http://jsfiddle.net/gppg7k6n/
And some jquery: