【发布时间】:2014-12-22 15:28:42
【问题描述】:
这是我的挑战:我有一张不动产的图像,该图像将随机加载到 200 像素宽的 DIV 中。因此,图像将被调整为 200 像素宽度和可变高度(保持比例)。我有四个单独的标题需要添加到图像上:
- 标题
- 价格
- 位置
- 表面
它们需要分别位于图片的中上、左下、左下和右下。所以我会有类似的东西:
--------------------------------
| Title |
| |
| |
|Price |
|Location Surface|
--------------------------------
我知道我可以通过将 div 置于相对位置并将文本置于绝对位置来将文本覆盖到图像上,但我似乎只能为下面的所有文本 div 设置一个位置,无论我有多少类使用。
有什么建议吗??
编辑:找到解决方案。作为参考,这里是生成的代码:
<div id="stampRandom">
<img class="stampImg" src="myphoto.jpg">
<div class="title"><span>Title</span></div>
<div class="prix"><span>Location</span><span><br><b>Price</b></span></div>
<div class="surf"><span><b>Surface</span></b></span></div>
</div>
还有 CSS:
#stampRandom {
position: relative;
top: 0px;
left: 0px;
width: 200px;
color: #FFF;
font-size: 80%;
}
#stampRandom {
position: relative;
top: 0;
left: 0;
width:200px;
color: #ffffff;
/* text-shadow: 1px 0 0 #000, 0 -1px 0 #000, 0 1px 0 #000, -1px 0 0 #000; */
font-size:80%;
}
#stampRandom img {
top:0px;
left:0px;
width:200px;
}
#stampRandom div {
position: absolute;
width: 200px;
}
#stampRandom div span {
background: rgb(0, 0, 0); /* fallback color */
background: rgba(50, 50, 50, 0.7);
}
.title {
top:2px;
width:100%;
text-align:center;
}
.prix {
bottom:0px;
left:0px;
}
.surf {
bottom:0px;
right:0px;
text-align:right;
}
感谢所有提供帮助的人!我被阻止了很多次,我的代码需要重做。新鲜出炉!
【问题讨论】:
-
您需要我们什么来帮助您?
-
给我们一些代码,天哪。