I believe everyone will see the effects of a carousel on all major websites, so I can't help but think about it. I checked the information and read the principles of the carousel, I tried to do it slowly, and the final effect was strong, but I still want to summarize it. Maybe it will help some friends who need it. Let's take a look at it. Implementation Principle
Think about it.
The width property value is set very wide until all your images can be mounted, and each image is used
- And left floating.
So when we move ul to the left and the distance is
- , The second
- Not moved
In this way, the image will not be displayed one by one?
Next we are setting
Overflow: hidden, then
The image outside the window is not displayed. Only the image that is moved to the current window is displayed. Is it perfect!
After talking about some principles, let's go directly to the code. Remember to introduce jquery.
This is the layout of p. Remember to add a border when doing so and delete it after doing so as to facilitate testing.
1 2 3 4 5