我有两个相互堆叠的 DIV。我希望 DIV 中的内容container
填充 DIV 的底部,box-2
否则我只能box-2
通过使用来扩展 DIV 长度的底部<br>
,当然这不能很好地工作,因为返回的结果会有所不同长度。下面,具有较浅边框 (DIV box-2
) 的 DIV 不会填充 DIV 的内容container
。应如何处理容器以确保其充满下部box-2
?CSS应该container
与合并box-2
吗?
这是一个基于https://stackoverflow.com/a/16611274/666891的示例,尽管它没有填充box-2
div。
这是相应的 HTML 代码,抱歉缺少缩进。
<div class="box-2">
<div class="border-top">
<div class="border-bot">
<div class="border-left">
<div class="border-right">
<div class="corner-top-left">
<div class="corner-top-right">
<div class="corner-bot-left">
<div class="corner-bot-right">
<div class="box-indent1">
<div id="boxtwo-header">
<div align="center">
<?php
echo "$myrow3[2]";
?>
</div>
</div>
<br><br><br>
<?php
echo '<div class="container">';
$q = mysql_query("SELECT * FROM name WHERE Field4 = '$cat'",$db);
while ($res = mysql_fetch_array($q)){
echo '<div class="item"><p><a href="page.php?page=' . $res['Field2'] . '&' . $res['Field6'] . '">' . $res['Field1'] . '</a></p></div>';
}
echo '</div>';
?>
<br>
<br>
<br>
<br>
<br>
<br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="clear"></div>
这是box-2
CSS:
.box-2 {
margin: 0 4px 39px 3px;
}
#boxtwo-header {
/* background: url(images/titles-act3.gif) no-repeat 0% 0%; */
position: absolute;
color: #000;
vertical-align: middle;
text-align: center;
font-family: Arial, Helvetica, sans-serif;
font-weight: bold;
font-size: 16px;
height: 26px;
width: 612px;
padding-top: 10px;
border-top-width: 0px;
border-right-width: 0px;
border-bottom-width: 1px;
border-left-width: 0px;
border-top-style: solid;
border-right-style: solid;
border-bottom-style: solid;
border-left-style: solid;
border-top-color: #E9E9E9;
border-right-color: #E9E9E9;
border-bottom-color: #E9E9E9;
border-left-color: #E9E9E9;
margin-top: 0px;
margin-right: -5px;
margin-bottom: 0px;
margin-left: -3px;
}
.box-2 .border-top {
background: #fff url(images/border-top2.gif) repeat-x 0% 0%;
}
.box-2 .border-bot {
background: url(images/border-bot2.gif) repeat-x 0% 100%;
}
.box-2 .border-left {
background: url(images/border-left2.gif) repeat-y 0% 0%;
}
.box-2 .border-right {
background: url(images/border-right2.gif) repeat-y 100% 0%;
}
.box-2 .corner-top-left {
background: url(images/corner-top-left2.gif) no-repeat 0% 0%;
}
.box-2 .corner-top-right {
background: url(images/corner-top-right2.gif) no-repeat 100% 0%;
.box-2 .corner-bot-left {
background: url(images/corner-bot-left2.gif) no-repeat 0% 100%;
}
.box-2 .corner-bot-right {
background: url(images/corner-bot-right2.gif) no-repeat 100% 100%;
width: 100%;
}
.box-2 .box-indent {
padding: 4px 33px 32px 37px;
}
.box-2 .box-indent1 {
position: relative;
padding-right: 4px;
padding-bottom: 5px;
padding-left: 5px;
}
.box-2 p {
padding: 0 0 15px 0 !important;
line-height: 1.417em !important;
color: #000000 !important;
}
container
为 MySQL 查询的输出创建两列布局的CSS:
.container {
width: 600px;
float: left;
border-width: 2px;
border-spacing: ;
border-style: outset;
border-collapse: collapse;
}
.container .item {
width: 300px;
float: left;
height: 30px;
padding-top: 2px;
padding-bottom: 2px;
}
.container .item a{
font-family: Arial, Helvetica, sans-serif;
font-size: 10.5pt;
font-style: normal;
font-weight: normal;
text-transform: capitalize;
color: #000000;
text-decoration: none;
}
.container .item a:hover {
color: #FF0000;