简体   繁体   English

使用Zurb的基础4在导航栏中的站点标题/徽标之前添加图像/图标

[英]Adding image/icon before site's title/logo in nav-bar with Zurb's foundation 4

I'm using Foundation for a project and I'm trying to add a small icon right before "SITENAME" in the top left corner. 我正在使用Foundation进行项目,并且尝试在左上角的“ SITENAME”之前添加一个小图标。 I've tried this css: 我已经尝试过此CSS:

.top-bar .name h1 a:before {
    background-image: url('images/logo.png');
    background-size:18px 18px;
    background-repeat: no-repeat;

}

but it doesn't seem to work. 但它似乎不起作用。 the image path is correct. 图像路径正确。

Here's the html: 这是html:

<nav class="top-bar" id="mainmenu">
    <ul class="title-area">
        <li class="name">
            <h1><a href="/site">SITENAME</a></h1>
        </li>
        <li class="toggle-topbar menu-icon"><a href="#"><span></span></a></li>
    </ul>
    <section class="top-bar-section">
    </section>
</nav>

How can I add a simple icon/image without hacking into foundation.css? 如何在不侵入Foundation.css的情况下添加简单的图标/图像?

If you are going to use the pseudo elements to show an image, you need to set content to '' (empty string), manually set the width and height , and set the display to either inline or inline-block . 如果要使用伪元素显示图像,则需要将content设置为'' (空字符串),手动设置widthheight ,并将display设置为inlineinline-block

Like this: 像这样:

.top-bar .name h1 a:before {
    background-image: url('images/logo.png');
    background-repeat: no-repeat;
    content: "";
    display: inline-block;
    height: 18px;
    margin-right: 10px;
    position: relative;
    width: 18px;
}

See a live demo here: http://plnkr.co/edit/ZeEBrfG2IchhqiNv5iWd?p=preview 在此处观看现场演示: http : //plnkr.co/edit/ZeEBrfG2IchhqiNv5iWd?p=preview

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

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