1
我已經編寫了一個可拖動div的代碼。結果是:我可以在屏幕上移動div,但無法使用滾動條查看div內的內容。示例代碼:如何使用滾動條查看可拖動div中的長內容?
HTML代碼:
<div class="draggable">
<h2>This will drag the div</h2>
<div class="scroll">This won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag
the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the divThis won't drag the div</div>
</div>
JavaScript代碼:
$(document).ready(function() {
$('.draggable').draggable({
scroll: true});
});
CSS代碼:
.scroll
{
width: 100px;
height: 80px;
overflow: auto;
}
的問題是:當我嘗試向下滾動到看到更多的文字,它也隨着光標移動div。這讓我無法看到div內的隱藏內容。
的jsfiddle例如:http://jsfiddle.net/SswbX/90/
注:此問題只發生在器火狐瀏覽器
我想要的是查看使用滾動條在div裏面的內容。
真棒男人!太謝謝你了。 –