Css 如何将按钮与底部中心对齐?

Css 如何将按钮与底部中心对齐?,css,Css,我有一个具有4个流体块的响应性设计。 我希望提交按钮固定在底部中心。 问题是,按钮向右移动(但没有完全向右对齐) 这是我的css: #product-list{ width: 100%; padding: 0 40px; margin: 30px 0 0 0; position:relative; } article.products{ float: left; position:relative; width: 24%; margin-top: 5px; ma

我有一个具有4个流体块的响应性设计。 我希望提交按钮固定在底部中心。 问题是,按钮向右移动(但没有完全向右对齐)

这是我的css:

#product-list{
    width: 100%;
    padding: 0 40px;
    margin: 30px 0 0 0;
    position:relative;
}

article.products{
float: left;
position:relative;
width: 24%;
margin-top: 5px;
margin-bottom: 5px;
margin-right: 0;
text-align: center;
border: 1px solid #C0C0C0;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
-ms-border-radius: 5px;
-o-border-radius: 5px;
border-radius: 5px;
padding: 10px;
    background: #fbfbfb;
    background-image: -ms-radial-gradient(center, ellipse farthest-corner, #FFFFFF 90%, #EFEFEF 100%);
    background-image: -moz-radial-gradient(center, ellipse farthest-corner, #FFFFFF 90%, #EFEFEF 100%); 
    background-image: -o-radial-gradient(center, ellipse farthest-corner, #FFFFFF 90%, #EFEFEF 100%);   
    background-image: -webkit-gradient(radial, center center, 0, center center, 506, color-stop(.90, #FFFFFF), color-stop(1, #EFEFEF)); 
    background-image: -webkit-radial-gradient(center, ellipse farthest-corner, #FFFFFF 90%, #EFEFEF 100%);  
    background-image: radial-gradient(ellipse farthest-corner at center, #FFFFFF 90%, #EFEFEF 100%);
}



article.products input[type="submit"] {
position: absolute;
bottom: 5px;
left: 50%;
}
以下是html(删除了不必要的代码;它是框的动态循环):


您必须将输入放在父div中

<div class="parent_div">
<input name="Submit" type="Submit">
</div>

这是你的代码:

article.products input[type="submit"] {
    margin-left: 50%;
    margin-right: 50%;
    marging-bottom: 5px;
}

或者您可以在容器类中放置一个
padding bottom:5px
。您的选择。

为什么不使用左边距:自动和右边距:自动?将左边距:50%替换为左边距:自动和右边距:自动会给我相同的问题/位置。如果我删除绝对值,它会因为父对齐而完全居中,但是我会丢失底部:5pxOh,然后将其添加到您的.class css:padding bottom:5px;哇,这是最好的解决方案。非常感谢。
.parent_div {
position: absolute;
bottom: 5px;
width: 100%;
}
.parent_div input {
margin: 0 auto;
}
article.products input[type="submit"] {
    margin-left: 50%;
    margin-right: 50%;
    marging-bottom: 5px;
}