Styling list items, replacing bullet with fontawesome

荒凉一梦 提交于 2019-12-31 05:43:31

问题


I have to create a list like this

I have tried to replace bullet with fontawesome icon which worked but I am getting something like this

Notice, there is a spacing difference between both of them. My CSS is

.custom_list li {
 line-height:2em;
 padding-left:0px;
 padding-top:5px;
 padding-bottom:5px;
 font-size:14px;
 list-style-type:none;
 list-style:none;
}
.custom_list li:before {
 font-family: 'FontAwesome';
 content: "\f192";
 color: black;
 margin-right:15px;
}

HTML is

<ul class="custom_list" >
  <li>Medical Student Education</li>
  <li>Resident Training Education (Medicine, Osteopathic, Pharmacy)</li>
  <li>Fellowship Training Education (all medical subspecialties)</li>
  <li>Nursing Student Training Education</li>
  <li>Nurse Practitioner Education</li>
  <li>Nurse Continuing Education</li>
  <li>Physician Continuing Medical Education</li>
</ul>

What am i doing wrong?


回答1:


.custom_list li {
 line-height:2em;
 padding-left:0px;
 padding-top:5px;
 padding-bottom:5px;
 font-size:14px;
 list-style-type:none;
 list-style:none;
 display: table-row;
}
.custom_list li:before {
 font-family: 'FontAwesome';
 content: "\f192";
 color: black;
 margin-right:15px;
 display: table-cell;
}

You need to change your list format to table




回答2:


Beware in font awesome 5, you will need a different font name,

.custom_list li:before {
 font-family: 'Font Awesome 5 Free'
}



回答3:


.custom_list li {
 line-height:2em;
 padding-left:20px;
 padding-top:5px;
 padding-bottom:5px;
 font-size:14px;
 list-style-type:none;
 list-style:none;
}
.custom_list li:before {
 font-family: 'FontAwesome';
 content: "\f192";
 color: black;
 margin-right:15px;
 position:absolute;
  left:40px
}


来源:https://stackoverflow.com/questions/47440865/styling-list-items-replacing-bullet-with-fontawesome

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!