如何使用display:inline-block集中一个类?

时间:2014-04-07 06:56:29

标签: css css3 html

我有几个矩形框直接对齐1列,每个框都有一个内容。以前我有以下内容:

.frmPhases
{
    width:800px;
    border:solid 2px #CCC;
    background: #EEE;
    height:auto;
    padding:14px;
    position:relative;
    margin-bottom:50px;
    margin-top: 50px;
    margin-left: auto;
    margin-right: auto;
}

显示效果不错但有1个缺陷,其宽度不一致。所以每个新盒子都进来,我必须根据其内容的最大宽度手动设置其宽度。 (这需要id,这会使我的CSS代码真的很长)

现在我改进了代码:

.frmPhases
{
    width:auto;
    display:inline-block;
    border:solid 2px #CCC;
    background: #EEE;
    height:auto;
    padding:14px;
    position:relative;
    margin-bottom:50px;
    margin-top: 50p
    margin-left: auto;
    margin-right: auto;
}

现在它具有一致的宽度,但矩形框不是集中的。如果我想手动键入左边缘,这是集中它的唯一方法,这看起来很好,但在不同的分辨率上它没有。知道如何集中它吗?

0 个答案:

没有答案
相关问题