我创建了一个 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>
最佳答案
<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>
关于jquery - 滚动内部子 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11257169/