WEBLEB
Inicio
Editora de código
Iniciar sesión
Pro
Español
English
Français
Español
HTML
CSS
JS
1
2
3
4
5
Больше
10
15
16
.page { max-width: 400px; display: flex; text-align: center; border: 1px solid; padding: 10px; min-height: 500px; } .container { display: flex; width: 100%; } .left { display: flex; overflow-x: auto; } .tabs { display: flex; } span { display: block; padding: 2px; border: 1px solid; width: 100px; height: 20px; margin-right: 10px; } .right { flex: 0 0 120px; /* фикс ширина */ background: #eee; }
function scrollToItem(el) { console.log(el); el.scrollIntoView({ behavior: "smooth", inline: "center", block: "nearest" }); } document.addEventListener('DOMContentLoaded', () => { document.querySelectorAll('span').forEach(span => span.onclick = () => scrollToItem(span)); })
Preview
Open Advanced Editor
Publish Code
Full Screen
HTML
CSS
JS
1
2
3
4
5
Больше
10
15
16
.page { max-width: 400px; display: flex; text-align: center; border: 1px solid; padding: 10px; min-height: 500px; } .container { display: flex; width: 100%; } .left { display: flex; overflow-x: auto; } .tabs { display: flex; } span { display: block; padding: 2px; border: 1px solid; width: 100px; height: 20px; margin-right: 10px; } .right { flex: 0 0 120px; /* фикс ширина */ background: #eee; }
function scrollToItem(el) { console.log(el); el.scrollIntoView({ behavior: "smooth", inline: "center", block: "nearest" }); } document.addEventListener('DOMContentLoaded', () => { document.querySelectorAll('span').forEach(span => span.onclick = () => scrollToItem(span)); })
Preview
Validating your code, please wait...