Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Apr 2012
    Location
    St. Louis, MO
    Posts
    985
    Thanks
    7
    Thanked 101 Times in 101 Posts

    Question Force iframe to height of containing DIV

    Hello, everyone.

    I'm using jQuery to set the height of a div to 100%, then trying to set the height of an iframe within said div to 100%. It's not working.

    The outermost div is "position:fixed; top:0px; bottom:0px; left:0px; right:0px;", so it's 100% width and height. The iframe will go to 100% width, but not 100% height. I can set it to pixels, but I would prefer that it dynamically adjusts to the browser height.

    Code:
    alert($('#centerDiv').height()); // displays "930"
    //There is a "header" div above the contentDiv
    $('#contentDiv').height(Math.floor($('#centerDiv').height()-80));
    alert($('#contentDiv').height()); // displays "850"
    $('#fileUpload').height(Math.floor($('#contentDiv').height()));
    alert($('#fileUpload').height()); // displays "" and has a height of about 100px.
    I've worked with iframes, before, but never trying to position one quite like this. I'm sure I'm missing something simple. Any ideas?

    Thank you,
    Last edited by WolfShade; 03-04-2013 at 04:43 PM.
    ^_^

    If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
    *
    The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".

  • #2
    Regular Coder
    Join Date
    Apr 2012
    Location
    St. Louis, MO
    Posts
    985
    Thanks
    7
    Thanked 101 Times in 101 Posts
    Nevermind.. the one thing I hadn't yet tried was putting a style tag before the iframe and setting the iframe id height to 100%. That seems to have done it.
    ^_^

    If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
    *
    The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •