[英]How to change navbar divider into icon
I created a navbar
with foundations css. 我用基础CSS创建了一个navbar
。 I am using font-awesome for the icons. 我正在使用字体超赞的图标。 I want to change the divider from a line to an icon (a font-awesome icon to be precise). 我想将分隔线从一行更改为一个图标(准确地说是一个超棒的图标)。 I tried adding an icon to the divider div, it didn't do the trick for me. 我尝试将图标添加到分隔线div,但这对我没有帮助。 Any ideas? 有任何想法吗?
This is what it looks like right now: 这是现在的样子:
But I want to replace that line by an icon. 但是我想用图标替换该行。 For example, this picture uses a dot but I will use a star. 例如,这张照片使用一个点,但是我将使用一个星星。
<nav class="top-bar" data-topbar role="navigation" id="navbar">
<ul class="title-area">
<li class="toggle-topbar menu-icon">
<a href="#">
<span></span>
</a>
</li>
</ul>
<section class="top-bar-section">
<!--right nav section-->
<ul class="right">
<li class="">
<a href="#">Sign Up</a>
</li>
<li class="divider">
<i class="fa fa-star"></i>
</li>
<li>
<a href="#">sign in</a>
</li>
</ul>
<ul class="left">
<li>
<a href="#">Demo</a>
</li>
<li>
<a href="#">Features</a>
</li>
</ul>
</section>
</nav>
You are getting the problem because of the foundation framework which is overriding the css for <li class="divider"></li>
Use the css: border-right-width: 0px !important;
由于基础框架正在覆盖<li class="divider"></li>
的css,因此您遇到了问题。请使用css: border-right-width: 0px !important;
to force your own css to dominate the framework's. 强制您自己的CSS主导框架。 Also, width: auto !important;
同样, width: auto !important;
is necessary for proper margin of the divider icon with menu items. 为使带有菜单项的分隔符图标具有适当的边距是必需的。
Here is the fiddle with the icon - 这是带有图标的小提琴-
http://jsfiddle.net/mmtbhfyL/8/ http://jsfiddle.net/mmtbhfyL/8/
The only problem is the star icon is not vertically aligned. 唯一的问题是星形图标未垂直对齐。 For this you have to set custom padding in the li.divider
. 为此,您必须在li.divider
设置自定义填充。
The divider
class is forcing the element to have width: 0;
divider
类强制元素具有width: 0;
which hide the content of the element, such as your font awesome icon, to prevent this behavior you can override foundation class like this: 隐藏元素的内容(例如,字体真棒图标)以防止此行为,您可以像这样重写基础类:
.top-bar-section > ul > .divider, .top-bar-section > ul > [role="separator"] {
width: auto;
border: 0;
color: #fff;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.