嘿,我是css新手,但我知道这应该很简单。如果有人能很快帮我,这样我就不会再弄得头破血流了,那就太好了。
只有2个项目,我需要帮助放置。
一个400x200px的图像,我总是想要在中心(包括垂直和水平),这将是内容。还有一行我想要在底部居中的文本,那就是页脚。
提前谢谢。
发布于 2011-04-13 12:33:08
如果我理解你的要求,我认为你应该尝试一下,在css中使用页边距真的是可行的。;)
<html>
<head>
<title>Center</title>
<style type="text/css">
IMG.image1 {
position: absolute;
left: 50%;
top: 50%;
margin-left: -200px;
margin-top: -100px
}
#footer {
position: fixed;
bottom: 0;
text-align: center;
width: 100%;
}
</style>
</head>
<body>
<div id="Centeredcontent">
<img class="image1" width="400px" height="200px"></img>
</div>
<div id="footer">Footer</div>
</body>
</html>不管你的图片的总高度和宽度是减半还是负数,那么宽度应该是(左边缘:-200px;),顶部是(右边缘:-100px;)
发布于 2011-04-13 13:56:11
CSS中确实没有垂直居中的概念。这已经是一个很长时间的抱怨了。选项:
,
https://stackoverflow.com/questions/5644321
复制相似问题