【发布时间】:2013-11-12 05:29:32
【问题描述】:
我希望Divs 标记按钮位于父级div 的左下角,而不是它们现在所在的位置(即左上角)。有没有办法在不单独为每个 div 使用绝对位置的情况下做到这一点?这是 HTML 和 CSS。
CSS
.button
{
color: blue;
background-color: green;
width: 200px;
font-size: 20pt;
font-family: "Comic Sans";
position: relative;
float: left;
bottom: 0;
}
.button:hover
{
color: red;
background-color: purple;
}
#banner
{
height: 300px;
width: 80%;
background-color: pink;
position: absolute;
left: 10%;
right: 10%;
}
HTML
<div id="banner">
<div class="button" >Home</div>
<div class="button">About Us</div>
<div class="button">Contact Us</div>
<div class="button">Disciplines</div>
</div>
【问题讨论】:
-
如果您在问题中包含 jsFiddle,您将获得更快的答案。
-
@melevan:为什么要在 head 部分包含 div。阅读此The global structure of an HTML document。尝试设置
position absolute/fixed和bottom属性。