简体   繁体   English

如何获得令人惊叹的“图标作为项目符号”以获取属性列表样式位置:外部?

[英]How to get fontawesome "icons as bullet points" to get the property list-style-position: outside?

So there is this link on the official font-awesome website about using their icons in a bulletpoint: https://fontawesome.com/how-to-use/on-the-web/styling/icons-in-a-list所以在官方 font-awesome 网站上有一个关于在项目符号中使用他们的图标的链接: https ://fontawesome.com/how-to-use/on-the-web/styling/icons-in-a-list

Which states you can do it like this:哪个州你可以这样做:

<ul class="fa-ul">
  <li><span class="fa-li"><i class="fas fa-check-square"></i></span>List icons can</li>
  <li><span class="fa-li"><i class="fas fa-check-square"></i></span>be used to</li>
  <li><span class="fa-li"><i class="fas fa-spinner fa-pulse"></i></span>replace bullets</li>
  <li><span class="fa-li"><i class="far fa-square"></i></span>in lists</li>
</ul>

This looks like the icons are just being put in the li and not actually being the bullet points.这看起来像图标只是放在 li 中,而不是真正的要点。 Now I want to make sure whenever there's a new line of text for one of the bulletpoints, I want it to start on the same line as the text started on the previous line.现在我想确保每当有一个项目符号的新文本行时,我希望它与从前一行开始的文本在同一行开始。 However it's not doing that.然而,它并没有这样做。 It starts on the same line as the icon.它与图标在同一行开始。

An example of how it is:它是如何的一个例子:

在此处输入图片说明

An example of how I want it:我想要它的一个例子:

在此处输入图片说明

(Ignore the table around it) (忽略它周围的桌子)

I have already tried list-style-position: outside;我已经尝试过list-style-position: outside; , but: , 但:

list-style-position: outside;列表样式位置:外面; means that the bullet points will be outside the list item.意味着项目符号将在列表项之外。 The start of each line of a list item will be aligned vertically列表项的每一行的开头将垂直对齐

So it sounds logical that the next line of text aligns with the icon cause the icons are part of the content of the list items.因此,下一行文本与图标对齐听起来很合乎逻辑,因为图标是列表项内容的一部分。

By default, it already behave as you want默认情况下,它已经按照您的意愿行事

Notes : can't show you code in comment.注意:无法在评论中显示代码。 It isn't an answer to your question as you certainly have problem otherwise on your code.这不是您问题的答案,因为您的代码肯定有其他问题。

 <head> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> </head> <body> <ul class="fa-ul"> <li><span class="fa-li"><i class="fa fa-check-square"></i></span>List with<br/>new line</li> <li><span class="fa-li"><i class="fa fa-spinner fa-pulse"></i></span>List with<br/>new line<br/>new line<br/>new line<br/>new line</li> <li><span class="fa-li"><i class="fa fa-square"></i></span>hello, i have no new line</li> </ul> </body>

The fontawesome's bullets are positioned as you wanted, outside. fontawesome 的子弹可以根据需要在外面放置。

This is done by the inclusion of the fa-li class in the span tag.这是通过在 span 标签中包含 fa-li 类来完成的。

<span class="fa-li">

and the css that goes with it:以及与之配套的 css:

.fa-li {
    left: -2em;
    position: absolute;
    text-align: center;
    width: 2em;
    line-height: inherit;
}

This style is from fontawesome.css which needs to be included.此样式来自需要包含的 fontawesome.css。

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

相关问题 项目符号如何指向<li>标签有边框顶部使用 list-style-position: inside</li> - How can the bullet point inside an <li> tag have border-top using list-style-position: inside IE list-style-position:内部问题 - IE list-style-position:inside issues 带列表样式位置的段落换行:内部 - Paragraph wrap with list-style-position: inside CSS 属性列表样式位置项与项目符号不对齐 - CSS property list-style-position items doesn't align with bullets 如何在 html 中的列表内容及其编号之间保持单独的 alignment 将列表样式位置保留在内部? - How to keep separate alignment between the list content and its numbering in html keeping list-style-position to inside? 似乎无法摆脱社交媒体图标的要点 - Can't seem to get rid of the bullet points for the social media icons CSS表和列表样式位置错误? 解决方法? - CSS table and list-style-position bug? Workaround? 如何在 html 的无序列表上用食物图标替换项目符号 - how to replace bullet points with food icons on an unordered list in html 如何让 Bullet Points 显示在 HTML 标签中 - How to get Bullet Points to show in HTML Tabs 列表样式类型为无序列表:无; &list-style-position:内部; 在Firefox中占用额外的空间 - Unordered list with list style type: none; & list-style-position: inside; takes extra space in Firefox
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM