The Lodge is members-only design/dev videos and Office Hours.

Next Office Hours Session: "Implementing an SVG Icon System" Nov 30 - 6:00 PM Eastern

Scrolling div

  • # December 27, 2012 at 7:38 am

    Can we scroll any div using percentage instead px?

    Thanks in advance!

    # December 27, 2012 at 9:49 am

    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)

You must be logged in to reply to this topic.

There's a whole bunch of content on CSS-Tricks.

Search for Stuff   •   Browse the Archives

Get the Newsletter ... or get the RSS feed