开发者

CSS div height not stretching

开发者 https://www.devze.com 2023-03-07 22:46 出处:网络
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.

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 '开发者_StackOverflow<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?


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


.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%

0

精彩评论

暂无评论...
验证码 换一张
取 消