中心对齐调整大小,绝对div

时间:2013-11-18 21:13:28

标签: html css position center expand

我设置了一个页面但是我无法将新闻文章与页面中心对齐。

这是我到目前为止的链接 -

http://casb1.cloudapp.net/1016/1be61016ff9a717aa34c2adf7c5aa79e/3D%20Design/news%20articles/news.html

基本上我需要红色区域始终与边缘的距离相同,即使它扩展。这可能吗?

红色容器的css为position:absolute

非常感谢任何帮助。

PS。这只是我学习css和html的第一周,所以如果它很简单,请原谅我。

由于

2 个答案:

答案 0 :(得分:0)

我认为你不需要position:absolute你可以删除这个属性并添加它:

.collection {
   display:table;
   margin:auto;
}

答案 1 :(得分:0)

有很多可以改进,但是回答你的问题,我会做这样的事情:

.collection {
    position: static;
    display: inline-block;
}
.roundcont {
    text-align: center;
}

你基本上需要删除位置:绝对;来自.collection元素的属性,并将其显示更改为内联或内联块,然后设置text-align center;到它的父div,所以它现在看起来居中。