Html 垂直对齐div中的输入元素
我在上进行了搜索,以了解如何垂直对齐div中的输入元素。此div位于表单中。大多数问题,表单元素对于每个元素都有很多Html 垂直对齐div中的输入元素,html,css,Html,Css,我在上进行了搜索,以了解如何垂直对齐div中的输入元素。此div位于表单中。大多数问题,表单元素对于每个元素都有很多,或者有一个标记 我用这个CSS做了一个比较: .fillform{ position: relative; width: 100%; height: 33%; bottom: 0; background: rgba(225, 43, 50, 1.0); } .fillform div{ position: absolute; float: left; width: 100%
,或者有一个
标记
我用这个CSS做了一个比较:
.fillform{
position: relative;
width: 100%;
height: 33%;
bottom: 0;
background: rgba(225, 43, 50, 1.0);
}
.fillform div{
position: absolute;
float: left;
width: 100%;
height: 200px;
box-sizing: border-box;
border: 2px solid rgba(0,0, 255, 1.0);
}
.fillform div input{
float: left;
display: inline-block;
border: 2px solid rgba(255, 0, 0, 1.0);
box-sizing: border-box;
vertical-align: middle;
}
输入元素不能垂直对齐并且有边距
编辑:我不使用表格或
显示:表格单元格代码>添加位置:相对;最高:50%;保证金:1px
到.fillform div input
类,然后尝试以下操作:
.fillform{
width: 100%;
height: 33%;
bottom: 0;
background: rgba(225, 43, 50, 1.0);
}
.fillform div{
float: left;
width: 100%;
height: 200px;
box-sizing: border-box;
border: 2px solid rgba(0,0, 255, 1.0);
}
.fillform div input{
float: left;
border: 2px solid rgba(255, 0, 0, 1.0);
box-sizing: border-box;
position: relative;
top: 50%;
margin: 1px;
}
更改此规则:
.fillform div input{
display: block;
border: 2px solid rgba(255, 0, 0, 1.0);
box-sizing: border-box;
vertical-align: middle;
}
删除浮动:左
输入,只需让输入自然flow@ArnaudGueras它不起作用。你自己看看吧。从输入中删除float:left,它们只会获得空格removefloat:left编码>和添加显示:列表项代码>这里是