Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 垂直对齐div中的输入元素_Html_Css - Fatal编程技术网

Html 垂直对齐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%

我在上进行了搜索,以了解如何垂直对齐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%;
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,它们只会获得空格remove
float:left和添加
显示:列表项这里是