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);
答案 0 :(得分:1)
尝试添加到父div(带边框)css:
overflow: auto;