[英]How to align list Items with font-awesome icon next line text?
A picture paints a thousand words. 一张图片描绘了千言万语。 The text on the next line needs to align on same margin as above.
下一行的文本需要与上面相同的边距对齐。
HTML: HTML:
<ul>
<li>
<p><em class="fa fa-square"></em><span>Name and surnafdddddddddddddds sdgfh dh hdfh df hdsh dfh dsfh sdfhdsfh sdf hsdfhdsfhme</span></p>
</li>
</ul>
CSS: CSS:
ul{
display: table;
a{
padding-left: 10px;
}
span{
padding-left: 10px;
}
}
Update: 更新:
After @panther update: @panther更新后:
It is acceptable, however the fontawesome icon is now off centre. 这是可以接受的,但是这个fontawesome图标现在偏离中心。
You can try to use font awesome's built-in solution for lists : 您可以尝试使用字体awesome的内置解决方案列表 :
Use
fa-ul
andfa-li
to easily replace default bullets in unordered lists.使用
fa-ul
和fa-li
可以轻松替换无序列表中的默认项目符号。
In your case, the code will change to something like this: 在您的情况下,代码将更改为以下内容:
<ul class="fa-ul">
<li><i class="fa fa-square"></i><span>Name and surnafdddddddddddddds sdgfh dh hdfh df hdsh dfh dsfh sdfhdsfh sdf hsdfhdsfhme</li>
</ul>
You are probably looking for st. 你可能正在寻找圣。 like this.
像这样。
em {float: left;}
a, span {margin: 0 0 0 20px; display: block;}
Why not do these: 为什么不这样做:
Apply position
with a property value
of relative
to li
to avoid overlap 应用具有
relative
对于li
的property value
的position
以避免重叠
Insert the square with :before
selector and add position
with a property value
of Absolute
o its block of CSS
. 使用
:before
选择器:before
插入正方形,并添加property value
Absolute
position
或其CSS
块。
That way you can position it as needed. 这样你就可以根据需要定位它。 You have
top
, bottom
, left
, and right
properties to work with as you position it. 您可以在
left
top
, bottom
, left
和right
属性时使用它们。
HTML HTML
<ul>
<li>
<p>Some important text are to be place here.
It may or may not longer than the text we have here. You never know.
</p>
</li>
</ul>
CSS CSS
ul{
list-style-type: none;
}
li {
position: relative; /* Will help curtail overlap */
padding-left: 20px; /* Reserves a space for the square dot */
}
li:before {
content: '\f0c8';
position: absolute;
left: 0; /* Places the square dot at the space created by the LI padding */
font-family: fontAwesome;
}
i think you are expecting like this 我想你期待这样
http://jsfiddle.net/myYUh/88/ http://jsfiddle.net/myYUh/88/
I have added some example found on jsfiddle, i work around little bit. 我添加了一些在jsfiddle上找到的例子,我可以解决一些问题。 it might help you.
它可能会帮助你。
CSS CSS
.icons-ul{
width:100px;
}
.icons-ul>li {
position: relative;
}
icons-ul {
margin-left: 2.142857142857143em;
list-style-type: none;
}
ul, ol {
margin-top: 0;
margin-bottom: 10px;
}
.icons-ul .icon-li {
position: absolute;
left: -2.142857142857143em;
width: 2.142857142857143em;
text-align: center;
line-height: inherit;
}
[class^="icon-"], [class*=" icon-"] {
display: inline;
width: auto;
height: auto;
line-height: normal;
vertical-align: baseline;
background-image: none;
background-position: 0% 0%;
background-repeat: repeat;
margin-top: 0;
}
HTML HTML
<ul class="icons-ul">
<li><i class="icon-li icon-ok"></i>Bulleted lists (like this one)</li>
<li><i class="icon-li icon-ok"></i>Buttons</li>
<li><i class="icon-li icon-ok"></i>Button groups</li>
<li><i class="icon-li icon-ok"></i>Navigation</li>
<li><i class="icon-li icon-ok"></i>Prepended form inputs</li>
<li><i class="icon-li icon-ok"></i>…and many more with custom CSS</li>
</ul>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.