Bootstrap Image Slider Controls Does Not Work Properly - css

I'm working on a project in Bootstrap and I have added a simple image carousel with controls but the problem is that the controls does not work.. See my site here
As you can see you can not press on next and previous buttons to see other images. Here's my code:
<div class="row">
<div class="container">
<div class="col-md-3">
</div>
<div class="col-md-6">
<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="images/slideshow/1.jpg" alt="Los Angeles" style="width:100%;">
<div class="carousel-caption">
<h3>Los Angeles</h3>
<p>LA is always so much fun!</p>
</div>
</div>
<div class="item">
<img src="images/slideshow/2.jpg" alt="Chicago" style="width:100%;">
<div class="carousel-caption">
<h3>Chicago</h3>
<p>Thank you, Chicago!</p>
</div>
</div>
<div class="item">
<img src="images/slideshow/3.jpg" alt="New York" style="width:100%;">
<div class="carousel-caption">
<h3>New York</h3>
<p>We love the Big Apple!</p>
</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>
</div>
<div class="col-md-3">
</div>
</div>
</div>
Basically I have not found any kind of mistake in this code ,so if you know what is going wrong please let me know... thanks!

Your code has no problem. But You have used a older version of jQuery. Please update with newer version.
http://take.ms/Rbwmf
You can use this version. It is working perfectly with your code.
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
Thanks

You use the id="myCarousel" several time on this page.
You can only have ONE UNIQUE id per page. Removing the other id="myCarousel" fixes your issue.
Some additional info on IDs:
IDs are here in order for Javascript to target element quite easily. But while they make targeting element with JS easy, they need to be unique otherwise, the script won't be able to know which ID to target. There are many other way to target element with JS but this one stay one of the easiest one.
Small advice: even if you can, don't create IDs for CSS since they are not meant for that. Leave the IDs for use in JS. That will help to keep your code clean consistent.

Related

How Do I Fix the Carousel Slider Controls?

I'm trying to setup a CSS carousel, when I wrote the code the automatic sliding seems to work okay, although it seems little buggy. However the main issue is the prev and next controls don't work properly. Every time you click one of them they always start you from the active-item image so you can never fully click through the images.
<body>
<div class="container">
<div class="container-fluid">
<div class="row">
<div class="col-sm-12">
<div id="my-slider" class="carousel slide" data-ride="carousel">
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="images/parvazlogo.jpg" alt="program" />
<div class="carousel-caption">
<h1></h1>
</div>
</div>
<div class="item">
<img src="images/program1.jpg" alt="programming image" />
<div class="carousel-caption">
<h1>ParwazTech Will Bring your Ideas To Life!</h1>
</div>
</div>
<div class="item">
<img src="images/innovation.jpg" alt="innovation" />
<div class="carousel-caption">
<h1>Learn More about Us</h1>
</div>
</div>
<div class="item">
<img src="images/office.jpg" alt="deal struck" />
<div class="carousel-caption">
<h1>Start looking at deals now!</h1>
</div>
</div>
<a class="left carousel-control" href="#my-slider" 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="#my-slider" 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>
</div>
</div>
</div>
</body>
#MatiasFernandezMartinez
https://youtu.be/7Hr-EBEpVJ0 this is a video of the problem just to prove it is happening. As you can see the bottom three buttons work fine but the two left and right buttons bring up the problem I described
I'm assuming the problem is with my bootstrap or my jquery since the code does not bring you all problems

Accessing <img> inside nested <div> in CSS

I'm trying to fill carousel-background image fill carousel. But I'm not able to access tag from css.
<div id="carouselSlider" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<!-- data-slide-to part -->
</ol>
<div class="carousel-inner">
<div class="carousel-item active">
<div class="carousel-background"><img src="img/portfolio/fullsize/1.jpg"></div>
<div class="carousel-container">
<div class="carousel-caption">
<h2>We are xyz</h2>
<p>We help you to blah blah blah!</p>
Get Started
</div> <!--carousel-content-->
</div> <!--carousel-container-->
</div> <!--carousel-item-->
<div class="carousel-item">
<!-- similar content with <img>-->
</div> <!--carousel-item-->
<div class="carousel-item">
<!-- similar content with <img>-->
</div> <!--carousel-item-->
</div> <!--carousel-inner-->
<a class="carousel-control-prev" href="#carouselSlider" 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="#carouselSlider" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div> <!--carousel-->
CSS File:
#carouselSlider .carousel-inner .carousel-item .carousel-background img{
width: 100%;
height:400px;
}
I'm not able to edit image. Also is there a way to fill image in carousel without stretching it?
You can add classes to images. That line of code should look like
<div class="carousel-background"><img class="whateveryouwant" src="img/portfolio/fullsize/1.jpg"></div>
You're trying to navigate through your nested structure using classes but that's not how it works. Because you only have one image inside your carouselSlider div you could simply access it using:
#carouselSlider img {<your css here>}
But this will probably break when you have more images in there. If you can change that HTML you should probably add a class to your img or an id to to one of those inner divs and access it directly.
To avoid the image getting stretched check out the "background-size" CSS property. Either 'cover' or 'contain' should do it for you.

Auto height increase on bootstrap carousel as token-input list increase

I have a carousel which is actually a form.
One carousel item is a multi selectbox
How can i auto increase the height on only one carousel-item as the height of the multi select box increase.
The image 1 is how i get.
Image 2 how i want it.
Much thanks for much insights. I cannot refresh the carousel. It will unset my form inputs
<div class="row no-gutters" id="mob-carousel-row" [style.height.px]="mobileCarouselRowHeight">
<div class="col-1 col-sm-1">
<a href="#carouselExampleIndicators" role="button" data-slide="prev">
<i class="fa fa-angle-left mobile-form-nav" ></i>
</a>
</div>
<div class="col-10">
<div
#plMobileCarouselForm
id="carouselExampleIndicators"
class="carousel slide"
data-ride="carousel"
data-interval="false">
<div class="carousel-inner" role="listbox" id="mob-carousel">
<div class="carousel-item active">
<div class="form-group md-form mob inputbox">
<!-- first input box item -->
</div>
</div>
<div class="carousel-item active">
<div class="form-group md-form mob muti-select">
<!-- muti select box item need auto height -->
</div>
</div>
<div class="carousel-item active">
<div class="form-group md-form mob inputbox">
<!-- first input box item -->
</div>
</div>
</div>
</div>
</div>
<div class="col-1 col-sm-1">
<a href="#carouselExampleIndicators" role="button" data-slide="next">
<i class="fa fa-angle-right mobile-form-nav" ></i>
</a>
</div>
</div>
This is intended as a comment but I can't comment yet.
Since you haven't provided your CSS it's just guess work.
However, if you set the height to auto for the container that contains the input forms or select boxes, it will adjust itself as more options become available.
.carousel-item active {
height: auto;
}

React Onmouseover Suggestion

I'm learning build website using react and bootstrap css,
i have carousel, and separated navigation.
below example code of my carousel
class Home extends React.Component {
mousehover() {
... ???? .....
};
render() { return (
<div className="row">
<div id="carouselExampleIndicators" className="carousel slide col-9" data-ride="carousel">
<div className="carousel-inner" role="listbox">
<div className="carousel-item active">
<img className="d-block img-fluid" src="http://northdelawhere.happeningmag.com/wp-content/uploads/banner_sample300x300.jpg"
alt="First slide" />
</div>
<div className="carousel-item">
<img className="d-block img-fluid" src="http://www.raymiller.cc/thumbnail/exterior-beadboard-paneling-4-texture-plus-indoor-outdoor-siding-panel-beadboard-oak-sample-300-x-300.jpg"
alt="Second slide" />
</div>
<div className="carousel-item">
<img className="d-block img-fluid" src="..." alt="Third slide" />
</div>
</div>
<a className="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
<span className="carousel-control-prev-icon" aria-hidden="true"></span>
<span className="sr-only">Previous</span>
</a>
<a className="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
<span className="carousel-control-next-icon" aria-hidden="true"></span>
<span className="sr-only">Next</span>
</a>
</div>
<div className="col-3">
<ul className="flex-column">
<li data-target="#carouselExampleIndicators" data-slide-to="0" onmouseover={this.mousehover}>one</li>
<li data-target="#carouselExampleIndicators" data-slide-to="1">two</li>
<li data-target="#carouselExampleIndicators" data-slide-to="2">three</li>
</ul>
</div>
</div>
)}
}
React.render(<Home />, document.getElementById('root'));
i'm trying create event for my list using onmousehover, but failed.
anyone can help me for give clue / example for onmousehover event which will slide to target carousel (data-slide-to) ?
thank you very much.
Have a look at the SyntheticEvent section of the React docs, it explains how to use events like onMouseEnter and onMouseLeave in React:
Your event handlers will be passed instances of SyntheticEvent, a
cross-browser wrapper around the browser's native event. It has the
same interface as the browser's native event, including
stopPropagation() and preventDefault(), except the events work
identically across all browsers.
That said, depending on your use case, you be better off implementing the hover effect using CSS's :hover pseudo-class.

Twitter Bootstrap Carousel show empty content

I have implemented a twitter bootstrap 3 carousel into my page but have run into an issue with it. After sliding content showing blank.
<!-- CAROUSEL -->
<div id="myCarousel" class="carousel slide" data-ride="carousel" style="background-color:#B0A7A1 solid 1px;">
<!-- 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>
<!-- INDICATORS END -->
<!-- CAROUSEL INNER CONTENT -->
<div class="carousel-inner" role="listbox">
<!-- ITEM 1 -->
<div class="active item">
<img src="images/slider-bg.png">
<div class="container">
<div class="carousel-caption">
<h3 style="margin: 5px 0;">Senior Account Officers</h3>
<h5>Description</h5>
<h5 class="text-justify">If you're viewing this page via a the "next" and "previous" Glyphicon buttons on the left and right might not load/display properly due to web browser security rules.</h5>
<p><a class="btn btn-sm btn-danger" href="#">Read More</a></p>
</div>
</div>
</div>
<!-- ITEM 1 -->
<!-- ITEM 2 -->
<div class="item">
<img src="images/slider-bg.png">
<div class="container">
<div class="carousel-caption">
<h3 style="margin: 5px 0;">Felcon India required Experienced CA Officer</h3>
<h5>Description</h5>
<h5 class="text-justify">If you're viewing this page via a the "next" and "previous" Glyphicon buttons on the left and right might not load/display properly due to web browser security rules.</h5>
<p><a class="btn btn-sm btn-danger" href="#">Read More</a></p>
</div>
</div>
</div>
<!-- ITEM 2 -->
<!-- ITEM 3 -->
<div class="item">
<img src="images/slider-bg.png">
<div class="container">
<div class="carousel-caption">
<h3 style="margin: 5px 0;">Ca Fresher Internship Program</h3>
<h5>Description</h5>
<h5 class="text-justify" >If you're viewing this page via a the "next" and "previous" Glyphicon buttons on the left and right might not load/display properly due to web browser security rules.</h5>
<p><a class="btn btn-sm btn-danger" href="#">Read More</a></p>
</div>
</div>
</div>
<!-- ITEM 3 -->
</div>
<!-- CAROUSEL INNER CONTENT END -->
</div>
<!-- CAROUSEL END HERE -->
Any help would be appreciated. I have initialized the bootstrap .js file.

Resources