bootstrap Carousel questions - html

1) I use the carousel-thumbnails class. Somehow my thumbnails all align to the left side and on top of each other. How can I get them to align center one after another.
2)
I don't want to see the dots that indicate which photo is showing because I have the thumbnails, How can I get rid of them?
I just want to show 5 thumbnails although there are more photo's in my directory. How can I program it that as soon as I go to photo 4 he loads photo 6 and display in the thumbnails photo 2-6.
I tried hidden-xs in the class="carousel-indicators". That didn't work. But I think when it works it will also remove my thumbnails.
<div id="myCarousel" class="carousel slide carousel-thumbnails" data-ride="carousel">
<!-- Wrapper for slides -->
<div class="carousel-inner"role="listbox">
<div class="item active">
<img src="/fotos/auto.jpg" alt="Los Angeles" style="width:80%;">
<div class="carousel-caption">
<h3>test</h3>
<p>Info tekst</p>
</div>
</div>
<div class="item">
<img src="/fotos/visinstukjes.jpg" alt="vis" style="width:80%;">
<div class="carousel-caption">
<h3>Vis</h3>
<p>In stukjes of zoiets</p>
</div>
</div>
<div class="item">
<img src="/fotos/robot.jpg" alt="Chicago" style="width:80%;">
</div>
<div class="item">
<img src="/fotos/vrachtwagen.jpg" alt="New york" style="width:80%;">
</div>
</div>
<!-- Left and right controls -->
<a class="left carousel-control" href="#myCarousel" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#myCarousel" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
<span class="sr-only">Next</span>
</a>
<!--/.Controls-->
<ol class="carousel-indicators" >
<li data-target="#carousel-thumb" data-slide-to="0" class="active">
<img src="/fotos/auto.jpg" width="100">
</li>
<li data-target="#carousel-thumb" data-slide-to="1">
<img src="/fotos/visinstukjes.jpg" width="100">
</li>
<li data-target="#carousel-thumb" data-slide-to="2">
<img src="/fotos/robot.jpg" width="100">
</li>
<li data-target="#carousel-thumb" data-slide-to="2">
<img src="/fotos/vrachtwagen.jpg" width="100">
</li>
</ol>
</div>

use this code:
.mystyle{
background-image: url('bg.png');
width: 100px !important;
height: 100px !important;
background-position: center;
background-size: 100%;
background-repeat: no-repeat;
}
<div id="myCarousel" class="carousel slide carousel-thumbnails" data-ride="carousel">
<!-- Wrapper for slides -->
<div class="carousel-inner"role="listbox">
<div class="item active">
<img src="bg.png" alt="Los Angeles" style="width:80%;margin:0 auto">
<div class="carousel-caption">
<h3>test</h3>
<p>Info tekst</p>
</div>
</div>
<div class="item">
<img src="bg.png" alt="vis" style="width:80%;;margin:0 auto">
<div class="carousel-caption">
<h3>Vis</h3>
<p>In stukjes of zoiets</p>
</div>
</div>
<div class="item">
<img src="bg.png" alt="Chicago" style="width:80%;;margin:0 auto">
</div>
<div class="item">
<img src="bg.png" alt="New york" style="width:80%;;margin:0 auto">
</div>
</div>
<!-- Left and right controls -->
<a class="left carousel-control" href="#myCarousel" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#myCarousel" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
<span class="sr-only">Next</span>
</a>
<!--/.Controls-->
<ol class="carousel-indicators" >
<li data-target="#carousel-thumb" data-slide-to="0" class="active mystyle"></li>
<li data-target="#carousel-thumb" data-slide-to="1" class="mystyle"></li>
<li data-target="#carousel-thumb" data-slide-to="2" class="mystyle"></li>
<li data-target="#carousel-thumb" data-slide-to="2" class="mystyle"></li>
</ol>
</div>

Related

Accessibility - Bootstrap4 Carousel control tabbing is not going on to carousel-caption div while using the tab key from Keyboard

PFB is the example, Here I am using for Bootstrap Carousel control.
https://www.w3schools.com/bootstrap/tryit.asp?filename=trybs_carousel2&stacked=h
This example is working fine but when i am using tab key from the keyboard, control is not going on to anchor tag inside the div with class "carousel-caption".
I tried "tab-index" attribute for anchor tag to set the tabbing but tabbing is not working properly.
I want tabbing to work like below:
Left Arrow -> 1st anchor tag("LA is always so much fun!") -> 2nd anchor tag("Thank you, Chicago!") -> 3rd anchor tag("We love the Big Apple!") -> Right arrow
Could anyone please let me know how to implement tabbing for
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<!-- 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">
<img src="C:\Users\user1\Desktop\Sample\video-bg-static1.png" alt="Los Angeles" style="width:100%;">
<div class="carousel-caption">
<h3>Los Angeles</h3>
<a>LA is always so much fun!</a>
</div>
</div>
<div class="item">
<img src="C:\Users\user1\Desktop\Sample\video-bg-static2.png" alt="Chicago" style="width:100%;">
<div class="carousel-caption">
<h3>Chicago</h3>
<a>Thank you, Chicago!</a>
</div>
</div>
<div class="item">
<img src="C:\Users\user1\Desktop\Sample\video-bg-static3.png" alt="New york" style="width:100%;">
<div class="carousel-caption">
<h3>New York</h3>
<a>We love the Big Apple!</a>
</div>
</div>
</div>
<!-- Left and right controls -->
<a class="left carousel-control" href="#myCarousel" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#myCarousel" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
<span class="sr-only">Next</span>
</a>
</div>
You can't have tab index defined on an <li>, so we had to wrap our ul.carousel-indicators>li inside an anchor tag (which does work with tab index)...
Check the code which works with the same example and implements tabIndex as you wanted...
update: in light of questioner's comment, tab index now goes to the <p> under the heading on each slide instead of the carousel indicators; the href for these <a> tags to be updated by the user...
.carousel-indicators .active {
border-radius: 50%;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
<div class="container">
<h2>Carousel Example</h2>
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item active">
<img src="https://www.w3schools.com/bootstrap/la.jpg" alt="Los Angeles" style="width:100%;">
<div class="carousel-caption">
<h3>Los Angeles</h3>
<a class="active" tabindex="2" href="#myCarousel" data-slide-to="0">
<p>LA is always so much fun!</p>
</a>
</div>
</div>
<div class="item">
<img src="https://www.w3schools.com/bootstrap/chicago.jpg" alt="Chicago" style="width:100%;">
<div class="carousel-caption">
<h3>Chicago</h3>
<a class="" tabindex="3" href="#myCarousel" data-slide-to="1">
<p>Thank you, Chicago!</p>
</a>
</div>
</div>
<div class="item">
<img src="https://www.w3schools.com/bootstrap/ny.jpg" alt="New York" style="width:100%;">
<div class="carousel-caption">
<h3>New York</h3>
<a class="" tabindex="4" href="#myCarousel" data-slide-to="2">
<p>We love the Big Apple!</p>
</a>
</div>
</div>
</div>
<!-- Indicators -->
<ol class="carousel-indicators">
<li class="" data-target="#myCarousel" data-slide-to="0">
</li>
<li class="" data-target="#myCarousel" data-slide-to="1">
</li>
<li class="" data-target="#myCarousel" data-slide-to="2">
</li>
</ol>
<!-- Left and right controls -->
<a class="left carousel-control" tabindex="1" href="#myCarousel" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" tabindex="5" href="#myCarousel" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
According to your comment:
...Here I want to navigate between the carousel controls using the keyboard.
You can use keydown event. As reported in the documentation:
Keyboard events are only generated by , and anything with the contentEditable attribute or with tabindex="-1".
It's required to add tabindex="-1" to your carousel div plus the event handler.
$('#myCarousel').on('keydown', function(e) {
if (e.keyCode == 37) { // left arrow
$('#myCarousel').carousel('prev')
} else {
if (e.keyCode == 39) { // right arrow
$('#myCarousel').carousel('next')
}
}
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="container">
<div id="myCarousel" class="carousel slide" data-ride="carousel" tabindex="-1">
<!-- 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">
<img src="https://dummyimage.com/300x200/000/fff&text=1" alt="Los Angeles" style="width:100%;">
<div class="carousel-caption">
<h3>Los Angeles</h3>
<a>LA is always so much fun!</a>
</div>
</div>
<div class="item">
<img src="https://dummyimage.com/300x200/000/fff&text=2" alt="Chicago" style="width:100%;">
<div class="carousel-caption">
<h3>Chicago</h3>
<a>Thank you, Chicago!</a>
</div>
</div>
<div class="item">
<img src="https://dummyimage.com/300x200/000/fff&text=3" alt="New york" style="width:100%;">
<div class="carousel-caption">
<h3>New York</h3>
<a>We love the Big Apple!</a>
</div>
</div>
</div>
<!-- Left and right controls -->
<a class="left carousel-control" href="#myCarousel" data-slide="next">
<span class="glyphicon glyphicon-chevron-left"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#myCarousel" data-slide="prev">
<span class="glyphicon glyphicon-chevron-right"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>

CSS image-background of child element showing above image-border

I have the following markup:
<div id="carousel-is-sl-for-me" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#carousel-is-sl-for-me" data-slide-to="0" class="active">
<li data-target="#carousel-is-sl-for-me" data-slide-to="1">
<li data-target="#carousel-is-sl-for-me" data-slide-to="2">
<li data-target="#carousel-is-sl-for-me" data-slide-to="3">
<li data-target="#carousel-is-sl-for-me" data-slide-to="4">
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active" style="background-image: url('<?php bloginfo('template_url'); ?>/image/carousel-placeholder-01.jpg');">
<div class="container">
<div class="row">
<div class="col-md-5 col-md-offset-1">
<div class="panel panel-info">
<div class="panel-heading">1 in 4 people</div>
<div class="panel-body">
<p>...text goes here</p>
<a href="#" class="btn btn-primary">
<span class="glyphicon glyphicon-file"></span>
Download PDF
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Controls -->
<a class="left carousel-control" href="#carousel-is-sl-for-me" 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-is-sl-for-me" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
Notice how .item has a background applied to it as an inline style.
Then, in my CSS I have the following CSS border:
#carousel-is-sl-for-me {
border-image-slice: 15 27 15 27;
border-image-width: 15px 15px 15px 15px;
border-image-repeat: repeat repeat;
border-image-source: url('../image/marker-border-image-white-big-reversed.png');
border-style: solid;
}
However, the image background of the .item is hiding the image border of #carousel-is-sl-for-me:
Seeing as #carousel-is-sl-for-me is the parent element, I would have thought it's image borders would have been on top? Here is how they should look (if I hide the image background):
Is there an easy way to get around this?

make carousel centered in page?

<div id="imageCarousel" class="carousel slide" data-interval="3000" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#imageCarousel" data-slide-to="0" class="active"></li>
<li data-target="#imageCarousel" data-slide-to="1"></li>
<li data-target="#imageCarousel" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">
<div class="item active">
<img src="pics/space_1.jpg" alt="Space 1">
<div class="carousel-caption">
<h3>Space 1</h3>
<p>Infinite Boredom</p>
</div>
</div>
<div class="item">
<img src="pics/space_2.jpg" alt="Space 2">
<div class="carousel-caption">
<h3>Space 2</h3>
<p>Infinite Boredom</p>
</div>
</div>
<div class="item">
<img src="pics/space_3.jpg" alt="Space 3">
<div class="carousel-caption">
<h3>Space 3</h3>
<p>Infinite Boredom</p>
</div>
</div>
</div>
<a href="#imageCarousel" class="carousel-control left" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
</a>
<a href="#imageCarousel" class="carousel-control right" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
</a>
</div>
</div>
</div>
</div>
I have a bootstrap carousel that is working fine. However, when I make my window fullscreen, it does not span the entire width of the page. What styling would I use in order to do this?
Make sure you are following the correct nesting conventions. There may be an issue with your ".container" or ".container-fluid".
For more, reference: http://getbootstrap.com/css/#grid

Why does my bootstrap carousel have extra space on the sides?

I'm fairly certain that this is a simple fix, but I've spent hours on it and am not sure why I haven't been able to fix it. Any help would be greatly appreciated!
My HTML is standard bootstrap:
<div class="row">
<div class="container" id="main">
<div class=col-md-12>
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel" data-interval="5000">
<!-- 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" role="listbox">
<div class="item active">
<img src="*IMAGE*" alt="Power Grid">
<div class="carousel-caption">
<h3>HELLO</h3>
<p>World</p>
</div>
</div>
<div class="item">
<img src="*IMAGE*" alt="Power Grid">
<div class="carousel-caption">
<h3>GOODBYE</h3>
<p>World</p>
</div>
</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>
</div>
</div>
Here is my current CSS:
#main.container {
padding: 0 10% 5% 10%;
}
.carousel-inner > .item > img,
.carousel-inner > .item > a > img {
width: 50%;
margin: auto;
}
#carousel-example-generic {
border: #000000 solid 10px;
border-radius: 15px;
}

bootstrap carousel images overflowing the right hand grid col

I want to keep my carousel and nav bar in the middle 75% of the screen so i laid my screen out with a grid. I cant recreate it on fiddle but if you put it into you local you'll see; screenshot: see 'block 4' on top of the pic, thats where the col starts
<div class="col-sm-3">col1 </div>
<div class="col-xs-12 col-sm-6"> Carousel goes here </div>
<div class="col-sm-3">col3 </div>
The problem is that my images overflow onto the 3rd col, how can i get the carousel to stay in my middle cell/col?
full code below
<body>
<!--rows and cols structure -->
<div class="row">
<div class="col-sm-3">block1 </div>
<div class="col-xs-12 col-sm-6">
<!--carouselstart-->
<div class="container page-content">
<div class="hero row">
<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">
<img src="img/image1.jpg" alt="image 1 missing" title="Image 1">
<div class="carousel-caption">
<h3>caption1</h3>
</div>
</div>
<div class="item">
<img src="img/image2.jpg" alt="image 2 missing" title="Image 2">
<div class="carousel-caption">
<h3>caption 2</h3>
</div>
</div>
<div class="item">
<img src="img/image3.jpg" alt="image 3 missing" title="Image 3">
<div class="carousel-caption">
<h3>caption 2</h3>
</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>
</div> <!--end hero -->
</div><!--end of container-->
<!--nav bar goes here-->
<div class="col-sm-3">block4</div>
UPDATE....
I used thr chrome dev tools to alter some css and found that if i set the below to 100% then it fits perfectectly. How do i do this ?