gpt4 book ai didi

CSS:使用 float Div 垂直对齐图标旁边的文本

转载 作者:行者123 更新时间:2023-12-02 05:26:23 28 4
gpt4 key购买 nike

我正在尝试对齐图标/图像旁边的文本,我希望文本或图像垂直对齐但未应用垂直对齐,它可能与 float 有关

这是一张解释我想做什么的图片: enter image description here

这是我目前所拥有的:

---- HTML ---

<ul class="toolboxItems">
<li>
<div class="image">
<img src="someImage.png">
</div>

<div class="label">
<label>Lorem ipsum dolor sit amet....</label>
</div>
<li>

<li>
/* more of the same .... */
</li>
<ul>

---- CSS ----

ul.toolboxItems li {margin-bottom:10px;}
.image {float:left; width:30px;}
.label {float:left; width:150px; vertical-align:middle;}

我尝试使用 display:table/table-cell 但它没有用。

最佳答案

您可以使用 CSS 表格显示属性 supported in everything (IE 7 或更低版本除外)。

此处的工作演示:http://jsfiddle.net/Hgssm/1/

.toolboxItems {
display: table;
}

.toolboxItems li {
display: table-row;
}

.toolboxItems .image,
.toolboxItems .label {
display: table-cell;
width: 30px;
vertical-align: middle;
}

.toolboxItems .label {
width: 150px;
}

关于CSS:使用 float Div 垂直对齐图标旁边的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13018996/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com