1
我正在尝试用CSS来显示以标题叠加图层为中心的图像,并且在浏览器窗口太小(缩小到适合)时显示液体功能。如何制作液体,居中,带有标题覆盖图的图像?
我目前最好的尝试看起来像下面的HTML(使用谷歌的标志作为样本图像)
<div align="center">
<div class="container">
<img src="http://www.google.fr/images/logos/ps_logo2.png" class="picture" />
<h3 class="caption">Image Caption</h3>
</div>
</div>
与下面的CSS
.container {
position : relative;
max-width : 364px;
}
.picture {
border-radius:0.5em;
box-shadow: 0px 0px 0.5em #000000;
max-width:364px;
}
.caption {
position:absolute;
padding:0.25em;
top:1em; left:0; right:0;
color:black;
background-color:rgba(0,0,0,0.2);
text-align:center;
}
但是,如果行为会为中心的,因为我希望它适用于大型浏览器窗口,它不会缩小浏览器窗口... 另外我不需要IE支持,WebKit专用(iPhone/Android)就足够了,如果可能的话,我想尽量避免使用JavaScript 。
的jsfiddle准备与版本玩http://jsfiddle.net/kWH3C/1/
就是这样,谢谢!在某些时候,align = center一定是在挫折中得到的:) – 2011-04-27 13:48:09