css 固定在容器的底部
现在想把做出如图所示的效果,即,p固定在div 的底部,文本居中的效果!求大侠指导 展开
<div style="height:200px; width:200px; overflow:hidden; border-radius:20px; text-align:center;">
<img src="http://www.uedsc.com/wp-content/uploads/2014/03/MusicPlayerPSD.jpg" height="200" />
<p style=" background:rgba(0,0,0,.5); position:relative; top:-40px; color:#FFF; font-size:12px; padding:6px 0;">这里是文字</p>
</div>
注意:img标签没有结束标签
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<meta name="author" content="智能社 - zhinengshe.com">
<meta name="copyright" content="智能社 - zhinengshe.com">
<style>
.test{
width: 200px; height: 200px;
background-color: red;
}
.test span{
/*vertical-align: middle;*/
vertical-align: bottom;
}
.test em{
display: inline-block;
height: 100%;
/*vertical-align: middle;*/
vertical-align: bottom;
}
</style>
</head>
<body>
<div class="test"><span>123</span><em></em></div>
</body>
</html>
巨汗
巨汗
.....................................................................................................................................................................
外面的div用绝对定位,里面的东西用相对定位,完美解决问题!