开发者

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

开发者 https://www.devze.com 2023-02-26 03:21 出处:网络
I have this code: <li id=\"myLI\"> <a id=\"myAnchor\" href=\"#\"&g开发者_Python百科t; <img src=\"/icons/icon.png\">Click Here</a>

I have this code:

<li id="myLI">
<a id="myAnchor" href="#"&g开发者_Python百科t;
<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.

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;

0

精彩评论

暂无评论...
验证码 换一张
取 消