Ich mache einen Live-Twitter-Feed mit nodejs und websockets. Ich versuche, die Anzeige automatisch nach links zu scrollen, sobald das Browserfenster voll ist und es vertikal überläuft.Automatischer horizontaler Bildlauf, wenn Inhalt hinzugefügt wird
Das Projekt wird auf einem festen Bildschirm angezeigt, sodass Sie sich keine Gedanken über die Größenanpassung des Browsers machen müssen. Hier ist, was ich bisher:
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>
Duplikat von https://stackoverflow.com/questions/3742346/use-jquery-to-scroll-to-the-bottom-of-a-div-with-lots-of-text? –
@RichardHousham: Ich denke nicht ... OP spricht über horizontale Scroll. –
@ user1756180 überprüfen Sie dies https://stackoverflow.com/questions/45822166/auto-horizontal-croll-when-content-is-added/45822849#45822849 –