Forums

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

Home Forums JavaScript Script only expands sidebar to height of content

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #188545
    ErraticFox
    Participant

    Hello, I’m trying to make my sidebar expand the length of the website, not the content. But it’s only doing the contents height. So if it doesn’t fill the screen, then it cuts my sidebar off.

    Here’s my script:

    $(document).ready(function() { $('#sideBar').height($('html').height()); });

    I thought using html would make it fit the whole height of the screen. Here’s a image as an example of it going wrong: http://i.imgur.com/0WekbZa.png

    Can someone elaborate what I’m doing wrong? Thanks!

    (I’m extremely horrible at JS so please be easy.)

    #188547
    Paulie_D
    Member

    We cant diagnose an image…we need a live example of HTML/CS/Js code…ideally in a Codepen.io demo.

    Not the whole page…just enough to show the issue.

    #188552
    ErraticFox
    Participant

    I can’t really do a codepen.io, because it’s through a forum software. i.e. I’d have to transfer a lot of code over to codepen just to show one bug. But if you visit https://forum.leftalt.com/member.php?action=login you’ll see the sidebar cuts off.

    #188553
    Paulie_D
    Member

    Try giving the html and body tags a min-height of 100%.

    That should do it.

    #188557
    Alen
    Participant

    Larger

    As you can see, and like Paulie mentioned, you need to add min-height of 100% to html element for $('html').height() to give you correct number.

    Or you could just ask for the document height.

    $('#sideBar').css('height', $(document).height());

    Hope that helps,
    Alen

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