创建一个"div三明治"与固定高度面包切片div和一个可扩展的肉div

Ama*_*nus 7 html css

所以我有一个div三明治:三个div在彼此之上.由于背景图像,面包片都是固定高度的.肉是1px高的垂直中继器图像.当顶部面包片的溢出物质击中底部面包片的底部时,我需要一种方法来扩展肉.我认为肉和底部面包需要一个包装,但我不知道如何实现它.

这是我到目前为止所拥有的.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <style type="text/css">
        #top {
            position:relative;
            height:100px;
            background-color:pink;
            width:460px;
            word-wrap:break-word;
        }
        #wrapper {
            position:relative;
        }
        #expand {
            min-height:100%;
            height:auto;
            background-color:#EEEFFF;
        }
        #bottom {
            height:100px;
            background-color:#EEEEEE;
        }
        div.clear{
            position:absolute;
            width:100%;
            clear:both;
            height:1px;
            overflow:hidden;
            border:solid orange;
        }
    </style>
    <title></title>
</head>
<body>

    <div id="top">
        a<br/>a<br/>a<br/>a<br/>a<br/>a<br/>a<br/>a<br/>a<br/>a<br/>a<br/>a<br/>a<br/>a<br/>a<br/>a<br/>a<br/>a<br/>a<br/>a<br/>a<br/>a<br/>a<br/>a<br/>a<br/>a
    </div>
    <div id="wrapper">
        <div id="expand"></div>
        <div id="bottom"></div>
        <div class="clear"></div>
    </div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

我需要一种方法来使top的内容与底部包装中的"clear"相匹配,并将包装器向下移动.

dav*_*vid 7

这是你追求的效果吗?

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <style type="text/css">
        #top {
            position:absolute;
            height:100px;
            background-color:pink;
            width:460px;
            top:0px;
        }
        #wrapper {
            position:relative;
        }
        #expand {
            position:absolute;
            top:100px; /*height of top div*/
            bottom:100px; /*height of bottom div*/
            width:100%;
            background-color:#cccFFF;
        }
        #bottom {
            position:absolute;
            bottom:0px;
            height:100px;
            width:560px;
            background-color:#EEEEEE;
        }
        #text
        {
         position:relative;
        }
    </style>
    <title></title>
</head>
<body>

   <div id="wrapper">
      <div id="expand"></div>
      <div id="top"></div>
      <div id="bottom"></div>         
      <div id="text">
         a<br/>a<br/>a<br/>a<br/>a<br/>a<br/>a<br/>a<br/>a<br/>a<br/>a<br/>a<br/>a<br/>a<br/>a<br/>a<br/>a<br/>a<br/>a<br/>a<br/>a<br/>a<br/>a<br/>a<br/>a<br/>a
      </div>
    </div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)