Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/75.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,.container{ 浮动:对; 边框:1px纯蓝色; 高度:100px; } .集装箱img{ 宽度:80px; 高度:20px; 垂直对齐:中间对齐; 边框:1px纯红; } 使用Flexbox: .container{ 对齐项目:居中; 显示器:flex; 浮动:对; 边框:1px纯蓝色; 高度:100px; } .集装箱img{ 宽度:80px; 高度:20px; 边框:1px纯红; } 您可能应该使用flexbox .container{ display: flex; align

.container{
浮动:对;
边框:1px纯蓝色;
高度:100px;
}
.集装箱img{
宽度:80px;
高度:20px;
垂直对齐:中间对齐;
边框:1px纯红;
}

使用Flexbox:

.container{
对齐项目:居中;
显示器:flex;
浮动:对;
边框:1px纯蓝色;
高度:100px;
}
.集装箱img{
宽度:80px;
高度:20px;
边框:1px纯红;
}

您可能应该使用flexbox

.container{
display: flex;
align-items: center;
}
使用flexbox

.container{
display: flex;
align-items: center;
}
.container{
浮动:对;
边框:1px纯蓝色;
高度:100px;
显示器:flex;
证明内容:中心;
对齐项目:居中;
}
img{
宽度:80px;
高度:20px;
边框:1px纯红;
}

我希望您需要此输出

.container{
浮动:对;
边框:1px纯蓝色;
高度:100px;
}
.集装箱img{
宽度:80px;
身高:继承;
}