0

JSfiddleを見て.caption、div を class の下部に配置する方法を教えてください.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;
}
4

3 に答える 3

2

動作するposition: absoluteはずですが、次のように設定する必要があります.wrapper

.wrapper {
   position: relative;
}

デモはこちら: http://jsfiddle.net/sBxP2/4/

于 2013-08-07T05:15:52.567 に答える
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;
}
于 2013-08-07T05:23:36.757 に答える
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;
}
于 2013-08-07T05:21:49.993 に答える