My bootstrap carousel looks fine on desktop. The images are sized at 1200x400. But on mobile, it shrinks in so much that you can't ready the text on the images. Also, the navigation dots on the bottom of the player move up on top of the image.
1) How do I keep the size big enough to read the text on the images on mobile
2) How do I prevent the navigation dots on the bottom of the player from overlapping on my image on mobile
Here's my bootply:
http://www.bootply.com/huskydawgs/6UtgjHqm8f
Here's my html:
<div class="content-section-b">
<div class="container">
<div class="row">
<div class="col-lg-12">
<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" role="listbox">
<div class="item active">
<img class="img-responsive" src="http://www.onvia.com/responsive/apple_orange_testimonials.png" alt="Apples and Oranges">
</div>
<div class="item">
<img class="img-responsive" src="http://www.onvia.com/responsive/pears_mangos_testimonials.png" alt="Pears and Mangos">
</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>
</div>
<!-- /.container -->
</div>
<!-- /.content-section-b -->
Here's my css:
.content-section-b {
padding: 50px 0;
background-color: #3C5A78;
}
.carousel-control.left {
background-image:none;
}
.carousel-control.right {
background-image:none;
}
The problem is with the source images: they make it seem as if they were two different carousel items, when are in fact only one (apple-orange & pear-mango)... For a quick fix, you could make individual images from the sources (one for each fruit), hide the regular carousel through media queries on xs screens, and have a visible-xs carousel which has 4 instead of 2 carousel items.
It's not a great solution, though.
Fast example: http://www.bootply.com/U5uYwmnt1g
EDIT
Added the CSS to move the navigation dots on mobile not to overlap with the slides.
Expanding on why it's not the best solution:
-You should make the elements of the carousel be html elements, for a start, and not rely completely on images with shapes and text inside (everything on your images can be replicated easily with CSS, using images only for the fruits, or for the fruits and the cirle, if you don't care to make the circle with CSS)
-Once this is done, you could skip the 2nd carousel and modify the content of each slide through media queries (or helper classes) to get the desired result
-The CSS for the navigation dots uses the max-width query, which I understand is not usually recomended, though in this case it might be well used (if somebody can expand on this, please do)
Related
The default bootstrap carousel controls (left and right arrows) have links that span 100% of the height of the image in the carousel. I apologize as this may be a silly question, but how do you change this so that the links are only over the width and height of the arrows themselves?
You can see an example of what I mean under "Carousel" on the Boostrap docs(https://getbootstrap.com/docs/3.3/javascript/#carousel), and the code for the carousel is below.
<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="..." alt="...">
<div class="carousel-caption">
...
</div>
</div>
<div class="item">
<img src="..." alt="...">
<div class="carousel-caption">
...
</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>
I ended up here after doing a Google search, figured out on my own, so I'm adding my solution for Bootstrap 4.x so others can find this easy solution.
Since the icons are SVGs, adjusting BOTH the height and width will change the size of the icons. I had assumed they would change size if I increased the width, but that's not the case.
I used vw so they scale along with the screen, but you can use whatever units you want.
.carousel-control-next-icon,
.carousel-control-prev-icon {
width: 5vw;
height: 5vw;
}
add a class with 'carousel-control' and then add the following CSS.
or you can directly add this CSS to your code
#carousel-example-generic a.carousel-control {
height: 26%;
top: 33%;
width: 86px;
background: black;
//add your own CSS as you need
}
add in both .carousel-control.left and .carousel-control.right,
//change the margin to make the width and height more longer or shorter
margin: 100px 0;
//change the radius to make the point of the squared-hover looks rounded
border-radius: 60px;
add max-height & margin-top css values
<a style=" max-height:21%; margin-top:21%; " .....
to visually see the changes ( make aria-hidden="false" in first <span> & add background-color:blue; in <a> )
// note i tried this in bootstrap 4 not sure about 3
I am working on a website, and Twitter Bootstrap's carousel controls don't seem to be working. Clicking on indicators allows me to navigate, and the .carousel() function works, so the website scrolls through the images without any problems, but when I try to navigate using the buttons, I can move one image to either way, but after that clicking on the button just sends me back to the previous animation, before sending me to the slide I was already on. Here's my code
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div id="mainCarousel" class="carousel slide" data-ride="carousel" data-interval="6000">
<ol class="carousel-indicators">
<li data-target="mainCarousel" data-slide-to="0" id="cib1" class="active"></li>
<li data-target="#mainCarousel" data-slide-to="1" id="cib2"></li>
<li data-target="#mainCarousel" data-slide-to="2" id="cib3"></li>
<li data-target="#mainCarousel" data-slide-to="3" id="cib4"></li>
</ol>
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="/res/img/carousel/image1.png" />
</div>
<div class="item">
<img src="/res/img/carousel/image2.png" />
</div>
<div class="item">
<img src="/res/img/carousel/image3.png" />
</div>
<div class="item">
<img src="/res/img/carousel/image4.png" />
</div>
</div>
<a class="left carousel-control" href="#mainCarousel" 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="#mainCarousel" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
<script>
$("#mainCarousel").carousel();
</script>
Sorry if I explained it badly. I can't give anything visual. It seems to only be a problem with the website I'm making, because the code snippet works perfectly on here. In short, the left navigation button, for instance, will take me to the left once, but every time I click it after that, it moves to the right with no animation, before sliding back to the left, leaving me on the same slide I started on.
EDIT:
I am using Angular JS with routing on the same website, so that might affect how the carousel works.
See if this works, you have a few small errors in your code. You added / after the the end of the img source, not sure why. You forgot a # before the first main carousel in your ordered list, and the script at the end is unnecessary. I have done this for you here: https://jsfiddle.net/owq0e5vv/ and it seems to work fine.
I discovered the answer with a different question. After remembering that I had Angular Routing, I could narrow my search. Here's the answer:
Bootstrap carousel not working with angularjs
I am having an issue with the Bootstrap Carousel component, where the image is not sliding during transition.
Basically, the image seems to just get replaced (and does not slide) as can be seen from the Bootstrap site.
The other issue I am facing is that the image, when changing from one to the other seems to get overlaid on top of the left and right chevron icon controls.
I've scoured SO and found something similar:
Twitter Bootstrap Carousel Not Sliding
But the solution provided does not seem to apply for me as I am using the minified version of the Bootstrap JS which already has the transition function embedded.
Anyone came across a similar issue before?
As Leon has asked for some codes, I am practically perusing the same codes as posted in the Bootstrap website. Its just the issue has been the same where the image is not sliding in transition, but rather just getting invisible / visible and after a while where the slide gets visible, the chevron control seems to be behind the image (for a split second) and then gets on top of the image afterwards.
<!-- Carousel [START] -->
<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>
<li data-target="#myCarousel" data-slide-to="2"></li>
</ol> -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="assets/img/slider-images/header-images-01.jpg" alt="Slide 1" class="img-responsive">
</div>
<div class="item">
<img src="assets/img/slider-images/header-images-02.jpg" alt="Slide 2" class="img-responsive">
</div>
<div class="item">
<img src="assets/img/slider-images/header-images-03.jpg" alt="Slide 3" class="img-responsive">
</div>
</div>
<a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left glyphcolor" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right glyphcolor" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
<!-- Carousel [END] -->
UPDATE: The chevron icon also gets covered when I clicked on it to transition to the next slide.
Check out the css of div.item, if you have position: absolute / relative.
In other cases, try to create new document only your carousel, check if it works alone and if that's the case, your problem must be coming from earlier part of your code... Sometimes console wont show you what's wrong so you'll have to trace by yourself
let me explain you my problem.
I am building a website (here is the link http://www.greekorama.gr) and i'm having an issue with the carousel carousel and the navbar navbar-top-fixed.
If you try to scroll down using the side scroll-bar everything is fine.
But if you try to scroll down using the scroll-button on your mouse, then you will see that the top navbar is flipping.
Try to scroll and you will see what i am talking about.
It is happening on 4 pages. It's in greek language, here are the meanings
1)Αρχική Σελίδα = Home page
2)Παραγωγοί/Προϊόντα= Products/Producers
3)Καταλύματα= Accomodations
4)Επιχειρήσεις=Business
This is happening only on Google Chrome and Opera browsers (on IE,Safari and Firefox everything is ok).
I assume, that is something with the webkit going on. But i can not find out what.
The flipping is happening only bellow the carousel. I mean when you scroll down and carousel is dissapearing behind the navbar, at that moment the navbar is starting flipping.
Bellow is the top-fixed navbar code
<nav id="myNavbar" class="navbar navbar-default navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbarCollapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a id="a-brand" class="navbar-brand center-block" href="index.php?content=home" style="font-size: 1.3em; font-family:Garamond, Verdana, Helvetica, Geneva, sans-serif;">Δήμος Θεσσαλονίκης</a>
</div>
<div class="collapse navbar-collapse" id="navbarCollapse">
<ul class="nav navbar-nav center-block" id="ul-navmenu">
<li><a id="a-navbar" href="index.php?content=home"><span class="glyphicon glyphicon-home"></span> Αρχική Σελίδα</a></li>
<li><a id="a-navbar" href="index.php?content=product_search"><span class="glyphicon glyphicon-leaf"></span> Παραγωγοί/Προϊόντα</a></li>
<li><a id="a-navbar" href="index.php?content=accom_search"><span class="glyphicon glyphicon-tower"></span> Καταλύματα</a></li>
<li><a id="a-navbar" href="index.php?content=business_search"><span class="glyphicon glyphicon-briefcase"></span> Επιχειρήσεις</a></li>
<li><a id="a-navbar" href="index.php?content=links"><span class="glyphicon glyphicon-link"></span> Σύνδεσμοι</a></li>
<li><a id="a-navbar" href="index.php?content=contact_form"><span class="glyphicon glyphicon-envelope"></span> Επικοινωνία</a></li>
<form class="navbar-form navbar-right" role="search" id="search">
<div class="form-group">
<input type="text" style="font-family:Garamond, Verdana, Helvetica, Geneva, sans-serif;" class="form-control" name="username" placeholder="Αναζήτηση">
</div>
</form>
</ul>
</div>
</div>
</nav>
Bellow is the carousel code
<div class="homeCarousel hidden-xs">
<div id="myCarousel" class="carousel slide" data-interval="3000" 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>
<li data-target="#myCarousel" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">
<div class="active item">
<div class="carousel-caption">
<img src="images/thessaloniki1.jpg">
</div>
</div>
<div class="item">
<div class="carousel-caption">
<img src="images/alexander1.jpg">
</div>
</div>
<div class="item">
<div class="carousel-caption">
<img src="images/aristotelous1.jpg">
</div>
</div>
</div>
<a class="carousel-control left" href="#myCarousel" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span></a>
<a class="carousel-control right" href="#myCarousel" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span></a>
</div>
</div>
Both codes are not in the same file. They are in different files. All 4 carousels (one for every page i told you above) has the same code, the only difference is on image names and the carousel id ("homeCarousel", "prodCarousel" etc etc).
Any help is welcomed. Thanks in advance.
I had a similar issue on my page. The bootstrap navbar is placed along with the carousel on top of the page. When scrolling down the navbar gets position:fixed; . To avoid jumping I wrapped a container around my navbar, but noticed some flickering. I could resolve this my adding a higher z-index to the container, just make sure it's higher than the carousel, for example set the container to: position:relative; and z-index: 999;
Here is an example
https://jsfiddle.net/2xz4omLj/1/
I've put twitter bootstrap carousel along with the navbar-fixed-top on many websites and i don't get this error on any. This means that there is a problem inside your source code.
As you already realised it has to do with the carousel. If you delete it from your code, that bug won't appear, I did that with inspect element and the bug don't shows.
So, i think you should look for the problem inside the carousel code that you've placed on your website. The first thing that i see witch i know it is not good is that you've forced your carousel items to get 500px height. This is not a good thing because bootstrap does not work like that. You should use col-xs-12 class along with homeCarousel class, remove the item height and in the same time add the class img-responsive to all your images because they don't have that class currently. Twitter bootstrap is a responsive framework and you don't seem to understand that. Your carousel should contain images with the same size and they should be in a large scale to cover, probably at least 1200px width. So keep in mind, don't force any height, because responsive means that the width will fit and the height will autoset alone. Check again your ==**START**== carousel styles and remove the useless code and try to take advantage of bootstrap functions as they are, don't try to hack them very much because they are well done.
If this does not solve your problem, try to add a jsfiddle and i will edit it to work for you.
I found my solution here:
Bootstrap 3 Fixed Top Navbar 'Flickering' On Mobile Scrolling using jQuery One-Page Scrolling Effect
It doesn't tell you to which element you should apply the "backface-visibility: hidden". Initially I applied it to all elements, but this prevented the navbar-brand (which fell behind some other part of the navbar in my case) from being clickable. I ended up applying the backface-visibility to .navbar and some of my main containers.
I am having trouble making my bootstrap carousel display differently on a mobile device and a desktop screen.
Here is my HTML:
<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">
<center><img src="img.jpg" alt="..."></center>
<div class="carousel-caption">
<p>1st Screen</p>
</div>
</div>
<div class="item">
<center> <img src="img2.jpg" alt="..."></center>
<div class="carousel-caption">
<p>2nd Screen</p>
</div>
</div>
<div class="item">
<center><img src="img3.jpg" alt="..."></center>
<div class="carousel-caption">
<p>3rd Screen</p>
</div>
</div>
</div>
<!-- Controls -->
<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>
You can view the site here
The problem I am having is that my image sizes are appearing different on mobile devices, the 3 images I have are:
img.jpg Dimensions = 700 x 378 pixels
img2.jpg Dimensions = 700 x 378 pixels
img3.jpg Dimensions = 700 x 378 pixels
The images show up fine on desktop devices however on mobile devices the whole image seems to enlarge and some of image goes off the screen.
I want a media query which makes all images width:100% on mobile devices only.
Or is there is an easy way to preserve the size of images on all devices?
Appreciate the help
Bootstraps has a predefined CSS-class called "img-responsive". This should scale your images properly on mobile devices. An example:
<img src="..." class="img-responsive" alt="Responsive image">
Actually there is a jQuery slider plugin called Skidder. Doesn't have the same design as the default bootstrap carousel but is quite good. .img-responsive won't do.
Edit: In the carousel's CSS add height: 54vw; and it should work just fine. (Height/Width% = 54)