Understand Embla Carousel DOM manipulation
Embla Carousel uses minimal DOM manipulation to ensure high performance. It does not encapsulate or wrap your elements, meaning you retain full control over your markup. The library only modifies the DOM in two ways using inline translate3d transforms:
- Carousel container: Applies
translate3dto create the scrolling effect. - Carousel slides: Applies
translate3dto adjust positions, specifically for looping functionality.
Note: While the core library and framework wrappers follow this minimal approach, individual plugins may modify the DOM further.
<div class="embla">
<div class="embla__viewport">
<!-- The container receives an inline transform for scrolling -->
<div class="embla__container" style="transform: translate3d(73.5px, 0px, 0px)">
<!-- Slides may also receive inline transforms for looping -->
<div class="embla__slide" style="transform: translate3d(0px, 0px, 0px)">
<span>1</span>
</div>
</div>
</div>
</div>