Grow your CSS skills. Land your dream job.

get height.

  • # July 1, 2013 at 9:03 am

    how to get wrapper height if wrapper height: auto;? And when you get wrapper height then set on other element wrapper height.

    # July 1, 2013 at 9:20 am
    var h = document.getElementById('wrapperDiv').clientHeight;
    var h = document.getElementById('wrapperDiv').offsetHeight;

    clientHeight includes any vertical padding.

    offsetHeight includes any vertical padding, scrollBar, and the border.

    # July 1, 2013 at 10:20 am

    how to set on element height?

    # July 1, 2013 at 11:14 am

    Not sure what you’re doing or what the code is that you are weaving this into, but you could set it with:

    document.getElementById('otherDiv').style.height = h; //The variable used in the previous example defining 'h' as the wrapper height.
    # July 1, 2013 at 1:40 pm

    Doesn’t work.

    # July 1, 2013 at 2:02 pm

    Don’t you want the #block height to equal the height of the #wrapper when #block is clicked? You have it setting #block height equal to #block height which is redundant.

    # July 1, 2013 at 2:27 pm

    Am, yes I want to do block equal to wrapper. Can you show how to do it?

    # July 1, 2013 at 7:06 pm

    Sorry. You can’t change clientHeight [facepalm]. Use the style object of your div. Here’s a new pen:

    # July 2, 2013 at 3:30 am

    Thx :)

    # July 2, 2013 at 6:36 am

    .. delete this post

Viewing 10 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".