OffsetWidth returing an incorrect width?
Anyone got any idea why this might be returning a value that's 10 pixels out? The
.slider-container
has a width of 447
in devtools, but in my JS it's returning 457
This is basically my JS solution to my previous slider question, but those 10 pixels are annoying!
https://codepen.io/nwoodward/pen/yLEZddp?editors=11113 Replies
I think the issue you are having the caused by the scrollbar appearing after you resize the slides.
If you set
overflow-x: hidden;
on you .container
(removing the scrollbars) the issue disapears.
basically the value your code logs and the one you see in the devtools are not the same because the width of the element changed between the moment the log executes and the moment you look at the devtoolsAh, interesting, yeah that probably does explain the difference with the console log. I was just a bit confused because the pen in chrome also shows about a 10px difference (but I've just noticed that Firefox doesn't)
![](https://utfs.io/f/969adba1-7ab2-4376-89f0-72c0b1e0ef96-1nq2cb.png)