gpt4 book ai didi

javascript - 如果元素溢出应用动态滚动

转载 作者:太空宇宙 更新时间:2023-11-04 10:48:42 24 4
gpt4 key购买 nike

https://jsfiddle.net/Ldv10oz5/2/

如果列表大于 div,如何设置 div 动态滚动?

<div style="border: 1px solid black; width: 150px; height: 75px;">
<div data-bind="foreach: {data:teams}">
<div>
<span data-bind="text: name"></span>
</div>
</div>
</div>


function Team(name) {
var self = this;
self.name = name;
}

function AppViewModel() {
var self = this;
self.teams = ko.observableArray([
new Team('red'),
new Team('blue'),
new Team('yellow'),
new Team('green'),
new Team('orange'),
]);
}

var vm = new AppViewModel();
ko.applyBindings(vm);

最佳答案

尝试添加到父 div(带边框)css:

overflow: auto;

关于javascript - 如果元素溢出应用动态滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35160529/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com