请你看一下JSfiddle,让我知道如何使用.caption
在div的底部放置div .wrapper
。
我已尝试将position:absolute; bottom:5px;
规则添加到.caption
,但它将标题div定位在.wrapper
之外!
<div class="wrapper">
<div class="caption">Test</div>
<div class="main"></div>
</div>
这是css规则
.wrapper{
height:300px;
width:300px;
background-color:yellow;
}
.main{
height:100%;
width:100%;
}
.caption{
height:10%;
width:100%;
background: rgb(0, 0, 0) ; opacity: 0.7;>
margin-bottom:5px;
color:white;
}
答案 0 :(得分:2)
position: absolute
应该有效,但您需要将.wrapper
设置为:
.wrapper {
position: relative;
}
答案 1 :(得分:0)
试试这个
http://jsfiddle.net/shall1987/MwJsG/
CSS
.wrapper{
height:300px;
width:300px;
background-color:yellow;
position: relative;
}
.main{
height:100%;
width:100%;
}
.caption{
height:10%;
width:100%;
background: rgb(0, 0, 0) ; opacity: 0.7;>
margin-bottom:5px;
color:white;
position: absolute;
bottom: 0;
}
答案 2 :(得分:0)
.wrapper{
height:300px;
width:300px;
background-color:yellow;
position:relative;
}
.main{
height:100%;
width:100%;
}
.caption{
height:10%;
width:100%;
background: rgb(0, 0, 0) ; opacity: 0.7;
margin-bottom:5px;
color:white;
position:absolute;
bottom:0;
}