Spicing Up the Bootstrap Carousel with CSS3 Animations

Hi Marshall_Spevak,

Thank you for your comment (and the offer).

Are you using Bootstrap or Owl Carousel? On your website it seems to me you’re using the Bootstrap carousel. However, I can’t find any JS code to initialize the carousel. To have the carousel play on page load you need to either add data-ride="carousel" to the main carousel container div or initialize the component using JavaScript: $('#home-carousel').carousel();

If it doesn’t work, a good way to debug the problem is to isolate the component. Just copy and paste the bare-bone code needed for the carousel on CodePen and see if it works. You can share the URL here if you like so we can all look into it.

Cheers!

Yes, I am using both. Please see images for files used

I saw those files using developer tools.

I previewed main.js previously but couldn’t find the code to initialize the BS Carousel, although you’re using it on the page. Also, what I meant was that I didn’t see Owl Carousel on the actual webpage, although I saw the initialization code in main.js.

Did you try initializing the Bootstrap Carousel either using data-ride or the JS code the way I suggested above? If it doesn’t work, it’d be so much quicker to understand the problem if you isolate the component. I suggest using something like CodePen and pasting just the code needed for the BS Carousel to work, so if you can’t find what’s wrong with it, you can quickly share it here on the forum. It’s also easier for me to look at the code and test it without having to wade through lots of files.

Cheers!

OMG - worked perfectly - I added to this container code - div id=“home-carousel” class=“carousel slide” data-ride=“carousel” data-interval=“3000” I owe you dinner and beer. Thanks - Kinda of a cloudy day but you get the gist - https://portal.hdontap.com/s/embed/?stream=catamaran-ptz_eh-CUST

That’s a fantastic place!

I’m really glad the slider works (dinner sounds great: London - San Diego is a breeze) :smile:

Hey Antonella - Sure London to SD is easy. How about I fly there and we go to Khan’s in Bayswater. Went there many times last in London. Actually I have one more mystery I cannot solve. If you look at the site, webmentorshipsc.com when in phone responsive mode the menu expands but after click does not auto collaspe like another site I designed - leucadia-energy.com. Where do begin to attack this? Thanks.

Actually I figured it out! :slight_smile: added this to each link.
nav class=“collapse navigation navbar-collapse navbar-right” role=“navigation”

That’s great! I think for topics unrelated to the article it’s a good idea to open a new thread. Cheers :slight_smile:

1 Like

Hey Antonella,

Great stuff on this article! It had exactly what I was looking for.

I am writing to join the many that have a question for an experienced coder such as yourself.
I am currently doing FreeCodeCamp’s programming course, and there is a Tribute page challenge I must complete. Here is what I’ve created so far (please go easy on me I’ve only been coding for just over a month :slight_smile: )

As you can see in the CSS section, at the top, I’ve chosen 4 colors for my palette.
After altering some colors, when I decrease the browser window, the menu bar collapses but it is not viewable.
I’ve tried to look around for an answer but no luck.
Secondly, on my jumbotron containing the blockquote and the picture, I want the second part of the jumbotron (the picture) to go on top when the window size is decreased.
Any way around this?
I’m not in San Diego I actually just moved to London so I can definitely buy you a beer or two! lol
Cheers and thanks in advance.

Hi GBSimon,

Thanks for your comment, I’m glad you found the article useful. I’ve looked into your demo. To have the columns in the Jumbotron swap, you need to use BS .col-md-push-* and .col-md-pull-* classes. As for the navigation, you need to add a background-color to .navbar-toggle .icon-bar. Here’s a revised Pen: codepen.io/antonietta/pen/WxwQNb.

However, as I pointed out in the previous message, if you have queries that are unrelated to the article, please open a new thread. Cheers!

Hi Antonella,

I’m using this, and it works great for the first 3 cycles, then they stop resetting the animation and just are static. Any help?

Hi Dngretsch,

Could you please post a demo on something like CodePen. This will make it easier to debug. Cheers!

I can send you a link to the dev environment, but don’t want it public. Can you private email me? Thanks!

That would mean digging into your entire project to find out what’s causing the problem.

Rather, I’d like to see the carousel in isolation so that it becomes easier to single out the bug relating to this specific component. You can do so by replicating just the carousel-related code to something like CodePen and see if you’re getting the same bug. If you are, I can look at it and hopefully make a helpful suggestion. If you’re not, then something else on your project is interfering with the carousel and you can start switching other scripts off to find out what’s causing the issue.

1 Like

A post was split to a new topic: Please recommend JavaScript books or tutorials

Thanks a lot antonella for nice sharing. Hats off

1 Like

Hi Antonella!

I am having trouble trying to change de background color for an image.

I try on each class on the css, but id does not work. Can you help me with this please?

Thanks!

Hernan

Hi Hernan,

I’m not sure I understand the problem: do you mean changing the background color of a slide inside the carousel? Could you please post a link to the page where the problem is? Cheers!

Hi antonella, thanks for the fast answer!

What i ment is that i want to add a backgound image to a slide intead of the backroung color, but i can ´t figure it out. For example, i tried i tryed changing this line on the css file

.skyblue {
background-image: “img/image.png”;
}

but it does not work.

I am going in the right direction?

Thanks again!

Hernan

Hi Anotonella,
It´s me again.
I could´t get it working.

Here is a code pen so you han help me see what i did wrong.


For the example i used the same code you did.

Do i need to use specific image sizes?

Thanks in advance!