简体   繁体   English

如何将自定义图像图标添加到导航菜单?

[英]How do I add a custom image icon to my navigation menu?

I am using a template website, but need to add a different icon to each of the pages in the navigation menu. 我正在使用模板网站,但需要在导航菜单中的每个页面上添加一个不同的图标。 How can I do this without using a icon web font? 不使用图标网络字体怎么办?

  <ul class="chevron">
            <li><a href="index.html"><i class="icon-list"></i>Home</a></li>
            <li><a href="gallery.html"><i class="icon-camera"></i>About Me</a></li>
            <li><a href="about.html"><i class="icon-heart"></i>What is Occupational Therapy?</a>
<li><a href="about.html"><i class="icon-heart"></i>Why it works</a>
            </li>
            <li><a href="about.html"><i class="icon-heart"></i>Pricing</a></li>
            <li><a href="about.html"><i class="icon-heart"></i>Q&A</a></li>
            <li><a href="about.html"><i class="icon-heart"></i>Links</a></li>
            <li><a href="contact.html"><i class="icon-mail"></i>Contact</a></li>
          </ul>

You can simply use an image. 您可以简单地使用图像。

<ul class="chevron">
    <li><a href="#">Link 1 <img src="..." alt="..."></a></li>
    <li><a href="#">Link 2 <img src="..." alt="..."></a></li>
    <li><a href="#">Link 3 <img src="..." alt="..."></a></li>
</ul>

Then, in your CSS, you can target the image to give it a more appropriate width/height if it's not already scaled. 然后,在CSS中,如果图像尚未缩放,则可以将图像定位为更合适的宽度/高度。

ul.chevron li img{
    width: 50px;
}

(Copied from my comment. Even if OP doesn't have the SVG file, maybe this will prove useful to other users) (摘自我的评论。即使OP没有SVG文件,也可能对其他用户有用)

Do you have an SVG file for the icon font? 您是否有用于图标字体的SVG文件? You could import an SVG version of the font into http://icomoon.io/app and supplement with their free font sets. 您可以将字体的SVG版本导入http://icomoon.io/app,并补充其免费字体集。 I'm sure there's one in there you could use. 我确定您可以使用其中的一个。 I only mention icomoon because it's the only one I've ever used but http://fontello.com could work too. 我只提到icomoon,因为它是我曾经使用过的唯一工具,但http://fontello.com也可以使用。

You would import the SVG, select all of the icons, select any additional icons from the other icon sets, and then export the combined set. 您将导入SVG,选择所有图标,从其他图标集中选择任何其他图标,然后导出组合的集合。 You may have to change the names or adjust your stylesheet, but this should get you a working set that you can then use instead. 您可能需要更改名称或调整样式表,但这应该为您提供一个工作集,然后可以使用它。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM