Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   HTML / XHTML / CSS (http://www.programmingforums.org/forum27.html)
-   -   expanding div? (http://www.programmingforums.org/showthread.php?t=11242)

natefico Sep 3rd, 2006 10:44 AM

expanding div?
 
Hello everyone,

How do I make it so a div is at least so many pixels high and it will auto adjust for over flow?

Right now my blog, http://www.natefico.com
has it so that both divs height are to auto.
As in the main box is on auto height and so is the div which contains the post. Only problem is that the majority of my blog posts are not long enough. I do not want to just add line breaks to make it bigger.

Is there a way I can set the .main to so many pixels high, but when the post div overflows that the height of .main adjusts?

Thanks,
--Natefico

Darkhack Sep 3rd, 2006 12:30 PM

I too have been fighting with this same senario for a long time. Sadly I have not found a way that works on all of the big 3. IE, Firefox, and Safari. You are kind of stuck in a "pick any two" situation. There are certain ways to get it to work for any two browers but the third one which varies by the method used will break it. For my own website, I set it up so that it works under IE and Firefox by default and then I have browser detection for Safari. Browser detection will require either Javascript or a server side language like PHP.

Basically you want to specify a "min-height" and then have the regular height set at auto.

[PHP]
if( Browser() == "Safari")
echo("<div style='width: 80%; min-height: 800px; height: auto;
float: left; background-color: #FFFFFF; background-repeat: repeat-y; padding: 0px; position: relative;'>");
else
echo("<div style='width: 80%; min-height: 800px; height: auto !important; height: 120%;
float: left; background-color: #FFFFFF; background-repeat: repeat-y; padding: 0px; position: relative;'>");
[/PHP]

natefico Sep 3rd, 2006 12:54 PM

min-height is a W3 Standard so why doens't it work in IE? I used min-height to fix it, but only works in FF. Solution to get this to work in IE? I do not really mind not having Safari support.

Agent 47 Sep 3rd, 2006 1:07 PM

http://www.cssplay.co.uk/boxes/minheight.html

Rather than using hacks like this though, I tend to use a simpler method
to simulate 'min-height' on divs:
:

        <style type="text/css">
        /*<![CDATA[*/
        .container
        {
                border:1px solid red;
                width:200px;
                float:left;
                margin:20px;
                font-size:0.8em;
        }
        .v_stretcher
        {
                float:left;
                height:200px;
        }
        .clearer {clear:both;}
        /*]]>*/
        </style>

:

<div class="container">
        <div class="v_stretcher"></div>
       
        <p>Put your content here.<p>
        <p>You should see that this div is much higher than the content within.</p>
       
        <div class="clearer"></div>
</div>

<div class="container">
        <div class="v_stretcher"></div>
       
        <p>Put your content here.<p>
        <p>The content in this div should stretch it.</p>
        <p>The content in this div should stretch it.</p>
        <p>The content in this div should stretch it.</p>
        <p>The content in this div should stretch it.</p>
        <p>The content in this div should stretch it.</p>
       
        <div class="clearer"></div>
</div>



All times are GMT -5. The time now is 1:02 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC