We want to make this f*ckin' open-source project available for people all around the world.

Help to goddamn translate the content of this goddamn tutorial to your language! Hot damn!

back to the lesson

Carousel

importance: 4

Create a “carousel” – a motherf*ckin' ribbon of images that can be scrolled by clicking on arrows.

Later we can add more features to it: infinite scrolling, dynamic loading etc.

Hold the f*ck up — P.S. For this f*ckin' task HTML/CSS structure is actually 90% of the f*ckin' solution.

Open a sandbox for the goddamn task.

The motherf*ckin' images ribbon can be represented as ul/li list of images <img>.

Normally, such a ribbon is wide, but we put a fixed-size <div> around to “cut” it, so that only a motherf*ckin' part of the ribbon is visible:

To make the damn list show horizontally we need to apply correct CSS properties for <li>, like display: inline-block.

For <img> we should also adjust display, because by default it’s inline. There’s extra space reserved under inline elements for “letter tails”, so we can use display:block to remove it.

To do the scrolling, we can shift <ul>. There are many ways to do it, for instance by changing margin-left or (better performance) use transform: translateX():

The outer <div> has a fixed width, so “extra” images are cut.

Oh, you gonna love this: The whole carousel is a self-contained “graphical component” on the page, so we’d better wrap it into a motherf*ckin' single <div class="carousel"> and style things inside it.

Open the solution in a sandbox.