将图标添加到< li>菜单 [英] Adding icon to <li> menu

查看:82
本文介绍了将图标添加到< li>菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做一个学校项目,我被困在某个地方 想要在<li>标签之间放置图片(>><<).因为这是一个 在wordpress中导航是在php中完成的.

i am working on a school project and I am stuck at a point where i want to put an image ( >><< ) inbetween <li>-tags. Because it's a navigation in wordpress it's done in php.

这是我所拥有的:

img http://img825.imageshack.us/img825/253/screenshot20120529at305. png

这就是我想要的(查看菜单之间的蓝色东西) 项):

Here is what i want (look at the blue thingies in between the menu items):

img http://img703.imageshack.us/img703/253/screenshot20120529at305. png

我认为这是我需要放置image/menuitem.png的php. 但是哪里?帮助将不胜感激

I think this is the php where i need to put my image/menuitem.png.. but where? Help would very much be appreciated

function inkthemes_nav() {
    if (function_exists('wp_nav_menu'))
        wp_nav_menu(array('theme_location' => 'custom_menu', 'container_id' => 'menu', 'menu_class' => 'ddsmoothmenu',

'fallback_cb'=>'inkthemes_nav_fallback')); 别的 inkthemes_nav_fallback(); }

'fallback_cb' => 'inkthemes_nav_fallback')); else inkthemes_nav_fallback(); }

function inkthemes_nav_fallback() {
    ?>
    <div id="menu">
        <ul class="ddsmoothmenu">
            <?php
            wp_list_pages('title_li=&show_home=1&sort_column=menu_order');
            ?>
        </ul>
    </div>
    <?php
}

function inkthemes_home_nav_menu_items($items) {
    if (is_home()) {
    //home
        $homelink = '<li class="current_page_item">' . '<a href="' . home_url('/') . '">' . __('Home', 'themia') . '</a></li>';
    } else {
     //niet home
        $homelink = '<li>' . '<a href="' . home_url('/') . '">' . __('Home', 'themia') . '</a></li>/>';

    }
    $items = $homelink . $items;
    return $items;
}

推荐答案

尝试使用仅CSS解决方案:

Try to use a CSS-Only solution:

.ddsmoothmenu li {
  background: url('image/menuitem.png') no-repeat left center;
  padding-left:30px /* you have to adjust this manually */
}
.ddsmoothmenu li:first-child{
  background:none;
  padding-left:0;
}

这篇关于将图标添加到&lt; li&gt;菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆