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;
身高:继承;
}