scrolling a div of images horizontally with controls

后端 未结 1 2075
被撕碎了的回忆
被撕碎了的回忆 2021-02-11 09:30

I have a div with a bunch of images in it. With arrow controls to the left and right. I want my div to scroll right and left through the images with the arrow controls. I can

1条回答
  •  长发绾君心
    2021-02-11 09:39

    You can scroll left and right when clicking on your arrows by editing the scrollLeft DOM property of the scrolling element.

    Using jQuery, you can use the .scrollLeft() function to get or set the scrollLeft property - link to docs

    Here is a really simple page I just cooked up that shows the behavior:

    
    
    
    
    
    
    
    
    
    
    
    scroll left
    |
     scroll right
    
    
    800x800

    0 讨论(0)
提交回复
热议问题