我正在使用nodejs和websockets进行实时Twitter提要。我试图让显示器在浏览器窗口已满时自动滚动到左侧,并停止垂直溢出。添加内容时自动水平滚动
该项目将显示在固定屏幕上,因此无需担心浏览器调整大小。这是我到目前为止有:
socket.onmessage = function(message) {
var d = JSON.parse(message.data);
console.log(message.data);
var obj = {
text: d.text,
imgURL: d.imgURL,
}
updateView(obj);
}
var updateView = function(obj) {
container.append("<span class='inner'><img class='profile' src=" + obj.imgURL +
"></img><p>" + obj.text + "</p></span>");
}
span#container {
width: 1450px;
min-width: 100px;
min-height: 100%;
overflow-y: hidden;
overflow-x: scroll;
}
span.inner {
float: left;
border: 1px #333333 solid;
width: 469px;
height: 450px;
}
<div id="container"></div>
重复的https://stackoverflow.com/questions/3742346/use-jquery-to-scroll-to-the-bottom-of-a-div-with-lots-of-text? –
@RichardHousham:我不这么认为...... OP谈到了水平滚动。 –
@ user1756180检查了这一点https://stackoverflow.com/questions/45822166/auto-horizontal-scroll-when-content-is-added/45822849#45822849 –