将图标和文本垂直对齐为两列布局(Vertically align icons and text in a two column layout)

编程入门 行业动态 更新时间:2024-10-21 22:56:26
图标和文本垂直对齐为两列布局(Vertically align icons and text in a two column layout)

正如您在下面的图片中看到的,所有项目之间的间距都不同,看起来很糟糕。 这就是我目前所拥有的:

在尝试了大量不同的技巧之后,这是代码(这是一团糟): http : //pastebin.com/D8ekkj6S

如果有人能告诉我如何正确地做到这一点,我真的很感激。

PS:如果可能的话,我很想知道如何垂直对齐图标和中间点的相应文本。

As you can see in thew image below, all items have different spacing between them and simply look awful. This is what I currently have:

Here is the code (it's a mess) after trying tons of different tricks: http://pastebin.com/D8ekkj6S

I'd be really thankful if someone could tell me how to properly do this correctly.

PS: If possible, I'd love to know how to vertically align the icon and it's corresponding text by the middle point.

最满意答案

这样的事情对你有用:

HTML:

<div class="iconing"> <i class="icon-someIcon"></i> <p>Your text</p> </div>

CSS:

.iconing i, .iconing p { display: inline-block; vertical-align: middle; } [class^="icon-"], [class*=" icon-"] { width: 50px; height: 50px; line-height: 50px; }

用你的身高替换所有50px的实例。

Something like this should work for you:

HTML:

<div class="iconing"> <i class="icon-someIcon"></i> <p>Your text</p> </div>

CSS:

.iconing i, .iconing p { display: inline-block; vertical-align: middle; } [class^="icon-"], [class*=" icon-"] { width: 50px; height: 50px; line-height: 50px; }

Replace all instances of 50px with your height.

更多推荐

本文发布于:2023-08-07 17:39:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1465086.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:图标   布局   文本   Vertically   align

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!