参见英文答案 >
How to Vertical align elements in a div? 26个
对于以下HTML代码,
.shoppingform {
width: 400px;
height: 800px;
background: #7CB9E8;
/* url(some img)*/
padding-left: 15px;
padding-top: 10px;
color: white;
font-size: 12px;
font-weight: bold;
border-radius: 5px;
}
.customername {
border: 1px solid white;
color: black;
font-weight: normal;
padding: 10px 2px 5px 5px;
background: #B284BE;
width: 90%;
border-radius: 5px;
}
.customername {
height: 5%;
}
.customername {
margin-top: 5px;
}
.shoppingform > div > input {
border-radius: 5px;
width: 60%;
}
.formlabel {
display: inline-block;
width: 30%;
}
Step1: Your details
Name:
有许多div元素(比如customername),上面的代码没有,让问题变得简单.
标签和输入文本朝向div容器的顶部.
如何在div容器的中间垂直对齐标签和输入文本?要添加,表单中有多个div元素.