简体   繁体   English

LI中的CSS对齐图标和文本-垂直对齐以正常工作

[英]CSS Align Icon and Text in an LI - Vertical-Align to working

I have this code: 我有以下代码:

<li id="myLI">
<a id="myAnchor" href="#">
<img src="/icons/icon.png">Click Here</a>
</li>

I need to get the text to align in the middle of the icon (vertically), so I tried adding: vertical-align:middle but it's not working. 我需要使文本在图标的中间(垂直)对齐,因此我尝试添加:vertical-align:middle,但是它不起作用。

Can anyone advice please? 有人可以请教吗?

Thanks 谢谢

#myLI a#myAnchor img{
float:left;
margin:margin to center;
}

Margin to center is the values that you need to give according to the center of the text. 中心距是您需要根据文本中心指定的值。 eg margin : 5px 5px 0px 2px; 例如margin:5px 5px 0px 2px;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM