Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Scrolling div

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #41621
    vin308
    Member

    Can we scroll any div using percentage instead px?

    Thanks in advance!

    #119118
    Nile
    Member

    My first question would be why you want to do this — in which context do you need this to work?

    As a rough answer, first of all, you definitely can’t do this in CSS. The way in Javascript would be to do something like this:

    var percent = .2;
    var div = document.getElementById(“div”);
    div.scrollTop = percent * (div.scrollHeight-div.clientHeight);

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘CSS’ is closed to new topics and replies.