dongshenyu4638 2013-03-04 11:05
浏览 81

菜单项的高度不同

I am using wordpress on my site, marblesandmore.com, and have a theme that I currently am adjusting. The website is using a menu function build in to wordpress and the items use cufon and css.

The problem is the following: - the last 2 items have an offset...? - This is only visible in chrome and IE.

The php used:

<div id="menu">
            <?php $menuClass = 'nav superfish clearfix';
            $menuID = 'secondary-menu';
            $secondaryNav = '';
            if (function_exists('wp_nav_menu')) {
                $secondaryNav = wp_nav_menu( array( 'theme_location' => 'secondary-menu', 'container' => '', 'fallback_cb' => '', 'menu_class' => $menuClass, 'menu_id' => $menuID, 'echo' => false, 'walker' => new description_walker() ) ); 
            };
            if ($secondaryNav == '') { ?>
                <ul id="<?php echo $menuID; ?>" class="<?php echo $menuClass; ?>">
                    <?php if (get_option('estore_swap_navbar') == 'false') { ?>
                        <?php show_categories_menu($menuClass,false); ?>
                    <?php } else { ?>
                        <?php if (get_option('estore_home_link') == 'on') { ?>
                            <li <?php if (is_home()) echo('class="current_page_item"') ?>><a href="<?php bloginfo('url'); ?>"><?php esc_html_e('Home','eStore') ?></a></li>
                        <?php }; ?>

                        <?php show_page_menu($menuClass,false,false); ?>
                    <?php } ?>
                </ul> <!-- end ul#nav -->
            <?php }
            else echo($secondaryNav); ?>
</div> <!-- #menu -->

Css:

ul#secondary-menu { padding: 24px 0px 0px 23px; margin-top:24px; }
ul#secondary-menu li { padding-right: 20px; }
ul#secondary-menu li.current_page_item > a > strong, ul#secondary-menu li.current-menu-item > a > strong { color:#ede7c2; }
ul#secondary-menu li a strong { color:#000000;  text-transform: lowercase; font-size:16px; font-weight:normal; text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.3); margin-bottom:-3px; }
ul#secondary-menu li a span { color: #828282; font-family: arsmaquettepro,Helvetica, sans-serif; /*text-shadow: 1px 1px 1px #2d2d2d;*/ } 
ul#secondary-menu li a:hover { text-decoration: none; }
ul#secondary-menu li a:hover strong { color: #ede7c2; }
ul#secondary-menu li a:hover span, ul#secondary-menu li > a > span { color: #7b786a; }

There should be no difference between the first 4 items and the next 2.

Any idea what causes the offset?

Marblesandmore.com

EDIT: The answer below appears to be right, so the solution has to be in the css of the submenu:

ul#secondary-menu ul { width: 178px; background: url(images/secondary-dropdown.png) repeat-y; padding: 3px 0px 15px; box-shadow: 3px 6px 7px 1px rgba(0, 0, 0, 0.5); -moz-box-shadow:3px 6px 7px 1px rgba(0, 0, 0, 0.5); -webkit-box-shadow: 3px 6px 7px 1px rgba(0, 0, 0, 0.5); border-radius: 8px; -moz-border-radius: 8px; -webkit-border-radius: 8px; border-top-left-radius: 0px; -moz-border-radius-topleft: 0px; -webkit-border-top-left-radius: 0px; border-top-right-radius: 0px; -moz-border-radius-topright: 0px; -webkit-border-top-right-radius: 0px; border: 1px solid #ffffff; border-top: none; }
ul#secondary-menu li:hover ul, ul#secondary-menu li.sfHover ul { left:0px; top:43px; }
ul#secondary-menu li:hover ul ul, ul#secondary-menu li.sfHover ul ul { left:173px; top:-3px; border-radius: 8px; -moz-border-radius: 8px; -webkit-border-radius: 8px; border: 1px solid #232323; }                          
ul#secondary-menu ul li { background: url(images/secondary-dropdown-bottom.png) repeat-x bottom left; padding: 0px 0px 2px 2px; }
ul#secondary-menu ul li a { display: block; padding: 9px 3px 9px 28px; width: 145px; /*font-weight: bold; */font-size:14px; color: #000000; font-family: arsmaquettepro, Helvetica, Arial, sans-serif; /*text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.3); background: url(images/secondary-dropdown-bullet.png) no-repeat 15px 17px;*/ }
ul#secondary-menu ul li a:hover { background-color: #383838; color: #ede7c2; }
  • 写回答

3条回答 默认 最新

  • dourun2990 2013-03-04 11:30
    关注

    The last 2 object only have a 16px height while the other menu objects got 18px.

    edit: Sorry i just realized how bad this answer is without telling you where the problem is.. Will try to check it.

    i think it has something to do with the fact that the last 2 menu items has no submenus, somehow those ul tags for the submenus seem to add 2px to the height.

    Ok, this is not a "nice" solution, rather ugly to be honest, but i think it works. You can just target the 2 last items in the menu by using their id's and adding a margin at the top.

    #menu-item-3606, #menu-item-3604 {
    margin-top: 2px;
    }
    

    just remember that if u ever change those menu items in any way, they will have new identifiers so you would need to change the id's in the css. As I said, not a good solution but it works.

    There would also be problem if you for some reason added submenus to these two menu items.

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题