Emil Omir
Emil Omir

Reputation: 87

CSS div height not stretching

I'm programming a website and on a page I have dynamic content. To be specific I want to display some content in a div each. And the main div wont stretch upon this content.

#main{
    position:relative;
    background-image:url(images/main_middle.png);
    background-repeat:repeat-y; 
    width:850px;
    min-height:450px;
}
.intrebari{
    position:relative;
    width:400px;
    min-height:150px;
    padding:20px;
}

while($row=mysql_fetch_array($rezultat)){
    echo '<div class="intrebari">
                 <div id="upleft"></div>
         <div id="upright"></div>
         <div id="downleft"></div>
         <div id="downright"></div>
        '.$_SESSION['username'].' a intrebat:<br />
        '.$row['question'].'
         </div>';
}

What am I doing wrong?

Upvotes: 2

Views: 2073

Answers (2)

sathishn
sathishn

Reputation: 150

The internal div has to be cleared so the outer should know the height of the inner div you may use a class

.clear{
  clear:both;
}

and introduce it after your inner div inside outer div main

echo '<div class="intrebari">
                 <div id="upleft"></div>
         <div id="upright"></div>
         <div id="downleft"></div>
         <div id="downright"></div>
        '.$_SESSION['username'].' a intrebat:<br />
        '.$row['question'].'
         </div><div class="clear"></div>';

this will help you

If you have given float to intrebari, you need to give float left or right to main div to get the main wrap the inner content

Upvotes: 1

Ibu
Ibu

Reputation: 43850

.intrebari{
    position:relative;
    width:100%
    min-height:150px;
    padding:20px;
}

if you want to have the content of the div.intrebari stretch horizontaly make the width of value to 100%

Upvotes: 0

Related Questions