You need a wrapper div
around just the slides. It will have overflow: hidden
and a width
that is wider than the parent element. It is common to apply a negative margin-left
to the wrapper when sliding, but applying translate
to the slides will work too.
Things are easier if you are dealing with predetermined sizes, otherwise you want to use JS to get measurements from the slides and do some math. The width of the wrapper should be the sum of the widths of the slides. display: inline-block
will put everything on the same line if your wrapper is wide enough.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…