MozillaZine

Restoring [overflow auto] elements positions

Discuss how to use and promote Web standards with the Mozilla Gecko engine.
maxerist
 
Posts: 3
Joined: September 2nd, 2012, 12:58 am

Post Posted March 14th, 2019, 8:00 am

Hi,

I noticed that Firefox (Firefox developer edition 67.0b1 (64-bit)) has a nice "feature". It remembers and restores position of div elements with "overflow auto" css style.

The problem here is that I would like to
  • control it (selectively enable for some elements and disable for others).
  • find and use this feature in other browsers. It seems this doesn't work in Chrome.

I tried to find documentation about this, but failed. I remember myself struggling to control the scroll position of overflow elements some years ago and came up with a solution using anchor names. It seems like there were some changes during this period, otherwise I would notice this feature.

The test to reproduce is the source below. Scroll to any vertical position and reload the page (F5). You will get the last scrolling position in FF and top position in Chrome

Any information would be great,
thanks

Max

Code: Select all
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">

<style>
  .height100boxed {
    border: 1px solid rgb(150, 150, 180);
    height: 100px;
  }

  .scrollarea {
    padding: 5px;
    overflow: auto;
    width: 200px;
  }
</style>
</HEAD>

<BODY>
  <div class="scrollarea height100boxed">
    <p>test-test1</p>
    <p>test-test2</p>
    <p>test-test3</p>
    <p>test-test4</p>
    <p>test-test5</p>
  </div>
</BODY>
</HTML>

Return to Web Development / Standards Evangelism


Who is online

Users browsing this forum: No registered users and 1 guest