我有一个父容器,有很多div作为孩子。
父容器具有水平滚动。
如果完全不可见,我如何onclick
滚动到子div的末尾?
它应该适用于两个方向。
JS / jQuery的/ CSS
此处示例:https://jsfiddle.net/04mzhagr/
.parent{
width:100%;
white-space: nowrap;
overflow-y: hidden;
overflow-x: scroll;
}
.child{
display:inline-block;
padding:10%;
background-color:blue;
margin:10px;
}

<div class='parent'>
<div class='child'> test</div>
<div class='child'> test</div>
<div class='child'> test</div>
<div class='child'> test</div>
<div class='child'> test</div>
<div class='child'> test</div>
<div class='child'> test</div>
<div class='child'> test</div>
<div class='child'> test</div>
<div class='child'> test</div>
<div class='child'> test</div>
<div class='child'> test</div>
<div class='child'> test</div>
<div class='child'> test</div>
<div class='child'> test</div>
<div class='child'> test</div>
<div class='child'> test</div>
<div class='child'> test</div>
<div class='child'> test</div>
<div class='child'> test</div>
<div class='child'> test</div>
<div class='child'> test</div>
<div class='child'> test</div>
<div class='child'> test</div>
<div class='child'> test</div>
</div>
&#13;
答案 0 :(得分:0)
<div id='parent' class='parent'>
<div class='child'> test</div>
<div class='child'> test</div>
<div class='child'> test</div>
<div class='child'> test</div>
</div>
<script>
var parent = document.getElementById("parent");
parent.scrollLeft = parent.scrollWidth;
</script>