dongyue1988 2013-08-15 17:01
浏览 21

活动链接到Wordpress页面中的帖子

I have been reading around about how to make the navigation link stay active, when inside a post[ single page ]. I haven't found any solutions so i created a mix of jquery and php, But i don't think this is the right way dough it work.

So I was thinking of how to optimize the code much more. Any ides ?

<?php 
if (in_category('news')){ ?>
    <script>
     $(".menu-item-46 a").css("border-bottom","#000 5px solid");
     $(".menu-item-46 a").css("padding-bottom","11px");
    </script>
<?php }elseif (in_category('network')){ ?>
    <script>
     $(".menu-item-47 a").css("border-bottom","#000 5px solid");
     $(".menu-item-47 a").css("padding-bottom","11px");
    </script>
<?php } ?>
  • 写回答

1条回答 默认 最新

  • douzhun8615 2013-08-15 17:07
    关注

    One way to tackle the problem is to take advantage of CSS.

    Have a class called "active", and append this to the parent element holding the menu you wish to show.

    Example:

    <div class="active">
         <div class="menu-item-46"><a>My Nav</a></div>
    </div>
    

    Then in your css file:

    .active .menu-item-46{
        border-bottom:#000 5px solid;
        padding-bottom:11px;
    }
    

    Another suggestion would be to give the menu items, a generic class, "menu-item", as well as an id "menu-item-##". So you css can simply be ".active .menu-item"

    评论

报告相同问题?

悬赏问题

  • ¥15 目详情-五一模拟赛详情页
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line