Hi
I’m new here and a noobie in JS/JQuery.
I’'m building a personal Website (live example here) with the latest Bootstrap framework.
I have a Bootstrap-Carousel Component for showcasing Works.
I didn’t want to have the captions displaying over the images, i wanted them just below the Carousel.
Setting the caption position to relative and positioning the caption div outside below images results in changing the position of the Controls Arrows too.
I found then a snippet for taking the Caption-Text out from the Carousel and putting it in a div outside the Carousel.
This works, but there is no more Carousel-Images related animation.
What I’m asking for now, is if there is a way to have any kind of animation for the new Caption based on this snippet?
For a css solution only in the default bootstrap carousel set up you could have just changed the bottom position of the caption assuming you don’t have loads of content in there (which seems to be true from your demo).
If you have caption content that wraps or needs to take up the flow then you will need to do what you have already done. You could animate it with CSS keyframes but it would require a class being added and removed from the current new caption item.
That would require the help of a js guru (which I am not )
I had a fiddle anyway and got the js to add a class that we could animate with CSS.
Hi Paul
Many thanks for taking so much of your time for helping me out.
Your first css-only suggestion goes in the same direction as some others I had already tried.
They all have one thing in common, the controls arrows are also repositioned and then you have to frickle around to find the right position at different breakpoints because I wanna have the arrows always vertically centered.
But your second suggestion, that’s the one!
This is really an excellent starting point to play around with. Based on your code maybe I can try to add also a slight fadeIn/FadeOut transition or delay or whatever before the sliding (which seams to be really in time with images) takes place.
So in absence of a big expert guru I choose you as my guru. Let’s start playing…
There is already an opacity effect and you can just mess around with the keyframe to make it happen differently. If you put in a 50% keyframe you can finish the slide before the fade in finishes. The timing of the animation can be elongated to cater for the slide finishing at 50%.
I updated the previous codepen with that example in place so you can see it in action.
It’s just a matter of adding in extra keyframes at whatever percentage you need and then adjusting the timing duration to cater for the effects you want. In my example I finish the slide in at 50% and therefore for the rest of the duration the element keeps fading by itself. Originally the slide in and fade finished at the same time so the effectwasn’t as pronounced.
Thanks a lot for the improvements.
Now I’m wondering if there is way to let slide out and fade out the old caption text before the new caption slides in with css:
That’s not strictly possible as the JS you are using is inserting only one caption when the button is clicked. There’s only one caption element in that section unlike the normal bootstrap caption where you have a series of caption elements.
The js is just copying one element at a time so the html for the new caption is just the one caption. You can’t slide one caption out and then slide in a new caption because you don’t keep a copy of the old caption.
However having said all that you can probably trick people into thinking that the slideout and in effect is happening to different captions if you do it quick enough and of course do it while the js is changing the html.
This requires changing the keyframes to first slide the element out to one side and then immediately sliding it back from the other direction.
Didn’t think about there is only one caption.
I think that’s nice enough now. Everything works. The emulation for the Carousels default slideIn/slideOut is there and I can keep control arrows in place.
Many thanks for helping and explanations. This helped a lot understanding whats going on, and maybe, who knows, one day I will also be able to write some code…