CSS Question: Fade transition for Carousel
See original GitHub issueIssue description
- components:
Carousel
- reactstrap version
#5.0.0
- import method
es6
(I started with a blank React ES6 app on stackblitz.com) - react version
#16.1.1
- bootstrap version
#4.0.0
What should be happening?
I’m trying to create a carousel in reactstrap that has a fade
transition rather than the slide
transition.
What is happening?
The carousel is rendered invisible. It is still there, occupying space in the layout and cycling through the slides, but nothing is visible.
Steps to reproduce issue
I started with a blank React ES6 app, added only the the carousel example in your docs, and then added custom CSS following this example:
.carousel-fade .carousel-item {
display: block;
position: absolute;
opacity: 0;
transition: opacity .75s ease-in-out;
}
.carousel-fade .carousel-item.active {
opacity: 1;
}
html,
body,
.carousel,
.carousel-inner,
.carousel-item {
width: 100%;
height: 100%;
}
.carousel {
position: absolute;
top: 0;
left: 0;
}
.carousel-item:nth-child(1) {
background-color: red;
}
.carousel-item:nth-child(2) {
background-color: blue;
}
.carousel-item:nth-child(3) {
background-color: yellow;
}
- Start with blank React ES6 app on https://stackblitz.com
- Add dependencies:
jquery
,popper.js
,bootstrap
,reactstrap
,react-popper
, andreact-transition-group
. - In
index.js
, importbootstrap/dist/css/bootstrap.min.css
- In
index.js
, replaceApp
class with code from the Carousel example. - Change
render()
call at the end torender(<Example />, document.getElementById('root'));
. - Add custom CSS to style.css as mentioned above.
- Add the following properties to the
<Carousel/>
:keyboard={false}
pause={false}
ride="carousel"
interval="2000"
slide={false}
className="carousel-fade"
Error message in console
There are no errors logged to the console.
Code
https://stackblitz.com/edit/carousel-fade?file=index.js
Is there a way to create a carousel with a fade transition in reactstrap?
Side note: I don’t understand why Bootstrap has the .carousel-fade
class if it requires custom CSS to actually make it fade…
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Change Bootstrap Carousel fade transition - Stack Overflow
Bootstrap 5 includes a "fade" effect that can be used by simply adding the carousel-fade class to the Carousel. By default, the transition...
Read more >Bootstrap Carousel Fade Transition: How To + Template
Changing the transition effect of a Bootstrap carousel to fade instead of slide, is easy: it can be done just by adding an...
Read more >5 Bootstrap Fade Carousel Slider - csshint - A designer hub
1. Bootstrap 4 Carousel Fade ; 2. Bootstrap Carousel Fade Transition ; 3. Fade to Zoom Carousel ; 4. Fade Carousel Slider ;...
Read more >carousel-fade - Bootstrap CSS class
Bootstrap CSS class carousel-fade with source code and live preview. ... transition-duration: .6s; transition-property: opacity; } .carousel-item.active, ...
Read more >Bootstrap 4 Fading Carousel Slider - YouTube
Get Our Full Bootstrap Website Building Course – Learn to build sites fast: https://goo.gl/6tzUxH Free Tech Courses - Web Design, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Here is the SCSS I came up with for a smooth transition without the white flicker at the beginning.
Just in case someone is still looking for a solution to this issue. Here is my way: just add className=“carousel-fade” in Carousel