[英]positioning a div at bottom of another div
I want to have a solid grey bar in a DIV called "bottomGrey" at the bottom of a container DIV called "contactCopy". 我想在名为“ contactCopy”的容器DIV的底部的DIV中有一个稳定的灰色条。
<div id="contactCopy">
<div id="contactLeft">
CONTACT
</div>
<div id="contactRight">
<iframe src="https://www.google.com/maps/embed?pb=!1m5!3m3!1m2!1s0x87e2349d140afa9f%3A0x9b41dc0528aa1d72!2s131+W+2nd+St+%23400%2C+Davenport%2C+IA+52801!5e0!3m2!1sen!2sus!4v1389913120076" width="100%" height="100%" frameborder="0" style="border:0"></iframe>
</div>
<div id="bottomGrey"></div>
<div class="clr"></div>
</div>
the CSS CSS
#contactLeft{
float:left;
width:30%;
padding:5%;
}
#contactRight{
float:left;
width:640px;
height:480px;
padding-top:5%;
padding-bottom:5%;
margin-left:5%;
position:relative;
}
#contactCopy{
position:relative;
}
#bottomGrey{
position:absolute;
bottom:0;
height:10%;
width:100%;
}
but it doesn't display at all, even if I remove the "contactLeft" and "contactRight" DIVS. 但即使我删除了“ contactLeft”和“ contactRight” DIVS,它也不会显示。 This should be simple but :( 这应该很简单,但是:(
Live site: http://estes.nbson.com/contact.html 直播网站: http : //estes.nbson.com/contact.html
It is displaying: its just got a white background and no content. 它正在显示:它只有白色背景,没有内容。 Add a background color to it and you'll see what I mean. 给它添加背景色,您会明白我的意思。
Just add this to your CSS: 只需将其添加到您的CSS中即可:
#contactCopy:after {
display: block;
height: 10px;
width:100%;
background-color: grey;
content: "";
clear: both;
}
With that you can remove <div id="bottomGrey"></div>
and <div class="clr"></div>
from your HTML structure, and get the grey border and clearing at the same time. 这样,您就可以从HTML结构中删除<div id="bottomGrey"></div>
和<div class="clr"></div>
,并同时获得灰色边框和清除效果。
Give it a background color, 100% width and some content. 给它一个背景色,100%的宽度和一些内容。 Also Assuming the clr class is a clear fix implementation. 同样,假设clr类是一个明确的修复实现。 Put it be for the bottom grey div. 放在底部的灰色div中。 So contact copy will have a proper height, and bottom grey will sit bellow both floated divs. 因此,联系人副本将具有适当的高度,并且底部灰色将在两个浮动div下方都位于波纹管之下。 No need for the absolute position. 无需绝对位置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.