uso scrollLeft para desplazarme a la derecha 50px
pero luego registro el valor de scrollLeft, es 49.599998474121094px no 50px
cómo hacer que se desplace 50px
gracias por su apoyo
function myFunction() { var elmnt = document.getElementById("myDIV"); elmnt.scrollLeft += 50; elmnt.scrollTop += 10; document.getElementById ("demo").innerHTML = "Horizontally: " + elmnt.scrollLeft + "px<br>Vertically: " + elmnt.scrollTop + "px"; } #myDIV { height: 250px; width: 250px; overflow: auto; } #content { height: 800px; width: 2000px; background-color: coral; } <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <p>Click the button to scroll the contents of div by 50px horizontally and 10px vertically.</p> <p><strong>Tip:</strong> Click the button many times to scroll the same amount each time.</p> <button onclick="myFunction()">Scroll contents of div</button><br><br> <div id="myDIV"> <div id="content"> Some text inside a div element.<br><br> Some text inside a div element. </div> </div> <p id="demo"></p> </body> </html>Lo más probable es que la ventana de su navegador Chrome esté configurada con un zoom del 125% , lo que lleva a este resultado incómodo:
49.599998474121094px
Establezca el Zoom al 100% y ahí está:
50px