【发布时间】:2010-09-10 09:43:02
【问题描述】:
我今天在整理一个快速的“正在建设”类型的页面时注意到一个不寻常的问题,我正在使用相对定位将文本移动到图像上。 (此页面是由 SO 的离线页面“启发”的,如果您关心的话)
<html>
<head>
<title>Bronco Marching Band</title>
</head>
<body style="background-color: #888;">
<div style="text-align: center;">
<img src="standby.jpg" width="799px" height="600px" alt="Please Stand By"
title="The Bronco Band website is down for a major upgrade. Please check back later."
style="width: 620px; height: 465px; opacity: 0.8;" />
<div style="color: #C69C6D; font-size: 397%; font-weight: bold; font-family: sans, arial, helvetica; position: relative; top: -300px; left: 0px;">
PLEASE STAND BY
</div>
</div>
</body>
</html>
似乎是之前相对定位的div所在的区域还在占用空间。即,如果没有定位,它会在 div 所在的图像下方留下空白。
有没有办法解决这个问题?
【问题讨论】:
-
供以后参考:只需将您的代码缩进四个空格,它不会在帖子或预览中呈现。