dsxrq28228 2015-06-16 17:41
浏览 46
已采纳

Wordpress索引页面上的特定CSS

I have a Wordpress site and I want to change certain CSS values in the header.php on the index page only. I have a div which is 100% width and border bottom to add an underline to the header.php

<div class="nav"> 

   ...content to create nav-bar ...

    <div class="hr"></div> <!-- remove on index.php -->

</div>

I don't want it to show, or affect anything on the index.php. (I don't want to target another header.php file for this one small thing)

  • 写回答

2条回答 默认 最新

  • duanlai1855 2015-06-16 17:52
    关注

    Wordpress has a template tag called body_class which is used to create contextual CSS hooks.

    <body <?php body_class(); ?>>
    

    You can then use it in your CSS as follows:

    .blog {}
    .blog.home {}
    /** if blog index is a page **/
    .page.blog {}
    

    see the documentation for the rather extensive list of possible output.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 通联支付网上收银统一下单接口
  • ¥15 angular有偿编写,
  • ¥15 centos7系统下abinit安装时make出错
  • ¥15 hbuildex运行微信小程序报错
  • ¥15 关于#python#的问题:我知道这个问题对你们来说肯定so easy
  • ¥15 wpf datagrid如何实现多层表头
  • ¥15 为啥画版图在Run DRC会出现Connect Error?可我Calibre的hostname和计算机的hostname已经设置成一样的了。
  • ¥20 网站后台使用极速模式非常的卡
  • ¥20 Keil uVision5创建project没反应
  • ¥15 mmseqs内存报错