如何根据div孩子增加div的大小?

时间:2014-05-14 13:29:05

标签: html css

我有两个div:

<div class="Content">
          <h1>Hello World !</h1
                 <div class="POST">
                      My Post ......
                  </div>

</div>

CSS(内容):

.Content
{

    position:absolute;
    left: 50%;
    margin-left:-220px;
    top: 165px;
    width:707px;
}

CSS(POST):

.Post
{
    position:absolute;
    top:404px;
    width: 669px;
    left: 23px; 
}

<div class="content">增加时,我想要一个像这样的css代码,其他<div class="parent">高度增加所以

2 个答案:

答案 0 :(得分:0)

你去:

HTML:

<div class="Content">
     <h1>Hello World !</h1>
           <div class="POST">
           My Post ......
    </div>

</div>

的CSS:

 .POST
    {
        width: 200px;
        height:100%;
        background:red;
    }

.Content
{
    background:blue;
    height:100px;
    width:200px;
}

http://jsfiddle.net/zaHAL/

请,还要学习如何编写代码......

答案 1 :(得分:-1)

使用此:

HTML

<div class="Content">
          <h1>Hello World !</h1>
                 <div class="Post">
                      My Post ......<br>
                     sdfasfasdadfasfdasfdasdf<br>
                     asfasfa<br>
                        sdfasfasdadfasfdasfdasdf<br>
                     asfasfa<br>
                        sdfasfasdadfasfdasfdasdf<br>
                     asfasfa<br>
                        sdfasfasdadfasfdasfdasdf<br>
                     asfasfa<br>
                  </div>

</div>

CSS:

.Content
{
    top: 165px;
    left: 50%;    
    width:100%;
    border:1px solid black;
}
.Post
{
    top:404px;
    width: 50%;
    height:100%;
    left: 23px; 
    border:1px solid black;
}