Spacing between the glyphicon and text?

别说谁变了你拦得住时间么 提交于 2019-12-10 14:44:50

问题


I am trying to add a glyph icon as part of an email address link. The icon shows but there is no spacing between the icon and the email address text (I want the hyperlink to include both the icon and the text... including the space). What's the best way to accomplish this?

       <a href="mailto:someone@somewheredotcom" title="Some Email">
        <span class="glyphicon glyphicon-envelope">someone@somewheredotcom</span>
    </a> 

回答1:


If using glyphicon just add one space after </span> tag like below

<a href="#" class="btn btn-primary"><span class="glyphicon glyphicon-user"></span> Individual</a>

If you using glyphicon along with font awesome library reference just add fa-fw at the end of class.

<a href="mailto:someone@somewheredotcom" title="Some Email">
    <span class="glyphicon glyphicon-envelope fa-fw">someone@somewheredotcom</span>
</a> 



回答2:


You can try to do this:

.glyphicon-envelope:before {
  margin-right: 5px;
}

Be aware that your custom css file should be included after bootstrap.css




回答3:


From http://getbootstrap.com/components/, see this note

Be sure to leave a space between the icon and text for proper padding.

So, you can modify the CSS if desired, for example using Bogdan's idea, or just by adding &nbsp; between the icon and your text:

<a href="mailto:someone@somewheredotcom" title="Some Email">
    <span class="glyphicon glyphicon-envelope" aria-hidden="true"></span>&nbsp;someone@somewheredotcom
</a>



回答4:


According to Bootstrap:

Icon classes should only be used on elements that contain no text content and >have no child elements.

You should put the email address outside of span:

<span class="glyphicon glyphicon-envelope fa-fw"></span>someone@somewheredotcom


来源:https://stackoverflow.com/questions/30290434/spacing-between-the-glyphicon-and-text

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