2

我想知道,我们如何使用 CSS 和 960.gs 将 div 置于屏幕中心,水平和垂直

4

2 回答 2

2

960.gs 不是相对居中(即使用百分比)。这是关于选择页面的宽度(在本例中为 960 像素)并将其分割。您可以通过选择要开始的网格并选择宽度来“居中”div(总网格 - 起始网格)。

对于网格本身的简单水平居中,您可以执行 960.gs 演示中的操作:

.container_12 {
  margin-left: auto;
  margin-right: auto;
  width: 960px;
}
于 2012-05-05T10:59:10.377 回答
1
div { 
    position:absolute;
    left: 50%;
    top: 50%;
    width:""px;
    height:""px;
    margin:half the length of width; half the length of height; 
}
于 2012-05-05T10:48:53.973 回答