【发布时间】:2009-07-12 06:53:40
【问题描述】:
我想要的是这个:http://www.freeimagehosting.net/image.php?11b1fcb689.png
编辑:添加了我正在尝试做的更完整的图片。我可以使用绝对定位使其看起来正确,但是当窗口尺寸太小时,内容会滑出页面而没有水平滚动条。这就是为什么我想对 div 使用相对定位。再次感谢。 http://www.freeimagehosting.net/image.php?75c33eaf6e.png
我只知道如何使用绝对定位的 div 来做到这一点,但是当窗口太小时,绝对 div 中的内容会滑出页面。本质上,图像在屏幕的左半边垂直居中并对齐。如果窗口太小,我宁愿有一个水平滚动条也不愿丢失部分图像。
任何帮助将不胜感激!
迈克
<!DOCTYPE html>
<html>
<head>
<title>Title</title>
<style>
body {
margin: 0;
}
.footer {
color: #202054;
text-align: left;
font-size: 12px;
text-decoration: none;
margin-left: 20px;
}
a { border: 0px; text-decoration: none; font-family: Verdana, "Lucida Grande", Helvetica, Arial, sans-serif; }
span { text-decoration: none; font-family: Verdana, "Lucida Grande", Helvetica, Arial, sans-serif; }
a.footer:hover {
color: #EE001E;
text-decoration: underline;
}
</style>
</head>
<body>
<img style="position: absolute; right: 50%; top: 50%; margin-top: -128px;" src="Resources/chart.png" width="432" height="256"/>
<div style="position: absolute; left: 50%; top: 50%; margin-top: -200px; width: 368px; height: 400px;">
<!-- text content -->
</div>
<div style="position: absolute; width: 100%; height: 20px; bottom: 20px;">
<a style="text-decoration: none;" href="http://www.company.com" >
<img class="footer" src="Resources/logo.png" alt="company" width="21" height="13"/>
</a>
<a class="footer" href="#">Terms of Use</a>
<a class="footer" href="#">Privacy Policy</a>
<span class="footer" style="color: #7E7E7E;">Copyright © 2009 Company Inc. All rights reserved.</span>
</div>
</body>
</html>
【问题讨论】:
-
似乎不需要绝对定位,但如果可能,请同时显示其他内容和网格线。
-
这个问题似乎是他之前问题的延续(在这里找到:tinyurl.com/swarts1,由于链接格式,TinyUrl'd),它可能有助于了解问题的历史。
-
是的,这是我老问题的延续。我已经添加了代码,因此无需查看旧帖子。此外,我链接到了一个更明确的布局图像。有了这些信息,你知道这种布局是否可行吗?
-
我尝试使用全屏 div 容器和溢出来解决问题,但没有成功。代码如下:如果有人有任何想法,请分享。我不知所措。迈克我很快就会在下面更新我的答案。感谢您更新信息。
标签: javascript html css