我正在使用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 –