Div Box中的Div框

dgP*_*son 0 html css center alignment

我已将页脚添加到EasyCareBath.com,我可以让div正常工作,除了".footer_box",它不会居中.我添加了"left:15%",当你把窗户向上吹时,它就不再对齐了.我错过了什么或者我对css做了太多的事吗?

.footer_spacer {
    height: 50px;   
}
.footer_wrapper {
    height: 375px;
    background-color: #e6dccb;
}
.footer {
    border-top: 10px solid #789E65;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.6);
    margin-top: 0px;
    /*min-width: 1007px;*/
    height: 235px;
    background-attachment: scroll;
    background-image: url(../images_footer/footer_bg.png);
    background-repeat: repeat-x;
    background-position: center top;
    position: relative;
}
.footer_box {
    height: 236px;
    width: 1007px;
    /*position: relative;*/
}
.footer_copyright {
    width: 100%;
    /* [disabled]height: 100px; */
    /*float: left;*/
    padding-top: 15px;
    position: relative;
    text-align: center;
    word-spacing: normal;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    font-weight: 100;
    font-variant: normal;
    text-transform: none;
    color: #354245;
}
#footer_col_01 {
    position:absolute;
    left:11px;
    top:3px;
    width:164px;
    /*height:230px;*/
    z-index:1;
}
#footer_col_02 {
    position:absolute;
    left:186px;
    top:3px;
    width:164px;
    /*height:230px;*/
    z-index:1;
}
#footer_col_03 {
    position:absolute;
    left:361px;
    top:3px;
    width:164px;
    /*height:230px;*/
    z-index:1;
}
#footer_col_04 {
    position:absolute;
    left:535px;
    top:3px;
    width:183px;
    /*height:230px;*/
    z-index:1;
}
#footer_col_05 {
    position:absolute;
    left:728px;
    top:3px;
    width:265px;
    /*height:230px;*/
    z-index:1;
    font-size: 14px;
}
footer {
    font-family: Arial, Helvetica, sans-serif;
    color: #fff;
    font-size: 11px;
    float: left;
    width: 100%;
}
footer a {
    color: #FFF;
    text-decoration: none;
}
footer a:hover {
    color: #FFF;
    text-decoration: underline;
}
footer h6 {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 16px;
    font-weight: 500;
    color: #00A1CC;
    line-height: 46px;
    /*margin-bottom: -2px;*/
}
footer li {
    line-height: 18px;
    list-style-type: none;
    margin-left: 12px;
}
.footer_img_center {
    text-align: center;
}
Run Code Online (Sandbox Code Playgroud)

Dav*_*ave 5

改变你的.footer_box规则:

.footer_box {
    height: 236px;
    width: 1007px;
    margin: 0 auto;
    position: relative;
    }
Run Code Online (Sandbox Code Playgroud)

margin: 0 auto;footer_box 的中心.

position: relative;使得你的绝对定位列基于footer_box而不是身体定位.

旁注/类比我一直很喜欢:将'auto'想象为将橡皮筋连接到连接到页面边缘的项目的那一侧......在这种情况下,'auto'在右侧和左边,所以 - 如果从左右两侧拉出橡皮筋,它将始终居中,无论屏幕尺寸如何.