jquery - 滚动内部子 div

标签 jquery css html scroll

我创建了一个 div,该 div 有两个子元素,一个是 ul,另一个是 div 我想将该内部 div 和字体的元素滚动到修复 ul。我无法在内部 div

周围添加任何其他 div

代码

<div style="width: 200px; overflow-x: auto; ">
<ul>
    <li>Some data</li>
    <li>some more data </li>
</ul>
<div style="height: 70px; width: 500px">
    <img src="http://www.fiveriverstech.com/wp-content/themes/fiverivers/images/about_s.jpg">
    <img src="http://www.fiveriverstech.com/wp-content/themes/fiverivers/images/about_s.jpg">
    <img src="http://www.fiveriverstech.com/wp-content/themes/fiverivers/images/about_s.jpg">
    <img src="http://www.fiveriverstech.com/wp-content/themes/fiverivers/images/about_s.jpg">
    <img src="http://www.fiveriverstech.com/wp-content/themes/fiverivers/images/about_s.jpg">
    <img src="http://www.fiveriverstech.com/wp-content/themes/fiverivers/images/about_s.jpg">
    <img src="http://www.fiveriverstech.com/wp-content/themes/fiverivers/images/about_s.jpg">
    <img src="http://www.fiveriverstech.com/wp-content/themes/fiverivers/images/about_s.jpg">
</div>
</div>​

Live Demo

最佳答案

<div style="width: 150px; overflow-x: auto;position:relative ">
    <ul style="position:fixed">
        <li>Some data</li>
        <li>some more data </li>
    </ul>
    <div style="height: 100px; width: 500px;margin-top:60px">
        <img src="http://www.fiveriverstech.com/wp-content/themes/fiverivers/images/about_s.jpg">
        <img src="http://www.fiveriverstech.com/wp-content/themes/fiverivers/images/about_s.jpg">
        <img src="http://www.fiveriverstech.com/wp-content/themes/fiverivers/images/about_s.jpg">
        <img src="http://www.fiveriverstech.com/wp-content/themes/fiverivers/images/about_s.jpg">
        <img src="http://www.fiveriverstech.com/wp-content/themes/fiverivers/images/about_s.jpg">
        <img src="http://www.fiveriverstech.com/wp-content/themes/fiverivers/images/about_s.jpg">
        <img src="http://www.fiveriverstech.com/wp-content/themes/fiverivers/images/about_s.jpg">
        <img src="http://www.fiveriverstech.com/wp-content/themes/fiverivers/images/about_s.jpg">
</div>
</div>

DEMO

关于jquery - 滚动内部子 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11257169/

相关文章:

jquery - 滚动条和导航栏的流畅流动

javascript - 由于添加 Logo ,单选按钮变得错位

不是来自 Chrome 的 Safari 的 CSS hack

javascript - jQuery .ready() 事件和在 javascript 中构建内容

javascript - 根据 div 高度显示展开/折叠按钮

javascript - 可以使用 bxslider getCurrentSlide 方法将类分配给事件幻灯片吗?

javascript - 附加元素的 jQuery FadeIn

javascript - 当用户到达页面底部时隐藏 div

javascript - 如何启用标签内的按钮或 div 悬停检测?

html - 图像旁边出现的元素符号点