0

In some cases browsers choose bad element for vertical scroll, when URL-hash in an anchor has passed. For example overflow:hidden element may choose.

I want to know, how the browsers are choosing an element to scroll in, when URL-hash is passed? Or how to prevent the bug and always use body or html containers for scrolling?

In my case - the structure is:
html -> body {display:flex;flex-direction:column} -> div -> section {display:flex} -> ... -> div#my_anchor
And section had choosed for scroll. I tried to turn off a scrips - no effect, it means scroll does browsers.

Alexander Goncharov
  • 1,572
  • 17
  • 20
  • 1
    If I understand you correctly, you tried to stop browsers from scrolling to `my_anchor` when `#my_anchor` is in URL? You can try using the javascript code in the accepted answer of this question: http://stackoverflow.com/questions/3659072/how-to-disable-anchor-jump-when-loading-a-page – Cave Johnson Oct 06 '16 at 00:04
  • @Andrew thanks, I do the same - manual scroll with JS. But i'm interested - why the`section` with hidden overflow is choosed .. By the way`window.scrollTo(0, 500)` - not works, it try to scroll `body` element instead `section` choosed for hash scroll. – Alexander Goncharov Oct 06 '16 at 00:32
  • Sorry I can't answer. Maybe it is trying to scroll to `my_anchor` but there is some bug or specific problem with scrolling to `display:flex` elements. `flex` is pretty new so maybe it is a bug that hasn't been fixed. – Cave Johnson Oct 06 '16 at 01:14
  • What if you put `display:flex` on a div container instead? Like this: `html > body > div {display:flex;flex-direction:column} > div > section > ...` – Cave Johnson Oct 06 '16 at 01:15

0 Answers0