【问题标题】:Wordpress Styling Not Carrying Over to Other Pages -- Why?Wordpress 样式没有延续到其他页面——为什么?
【发布时间】:2012-08-15 08:05:13
【问题描述】:

您是否曾经为 wordpress 标头设置样式,然后发现该标头在较低级别的页面上忽略了您的 CSS 样式?真的可以使用您的帮助来调试这个烦人的问题 - 谢谢提前!!

我在这里为朋友创建一个简单的投资组合网站:http://sundryspirit.com/

主页在页面顶部有一个全局标题,应该出现在网站的每个页面上:

<div id="header">
    <div id="header-top">                   
        <div id="logo">
            <a href="<?php bloginfo('url'); ?>">
            <h1>Sundry &amp; Spirit</h1>                
            <h2>Burning Man Apparel</h2>
            </a>            
        </div>

        <div id="mainNav">
            <?php wp_nav_menu(); ?> 
        </div>
    </div>
</div>

我现在在 style.css 文件中为这个头添加了一些基本样式:

#header {
width: 100%;
height: auto;
background: #e1e1e1;
opacity: 0.75;
margin: 0 auto;
max-width: 960px;
}


#header-top {   
height: 50px;
margin: 10px;
position: relative;
padding: 10px;
text-align: center;
}

这是一个令人讨厌的问题:基本的标题样式不会延续到其他页面上,例如 http://sundryspirit.com/gallery/

如果标头只是来自 header.php 文件,那怎么可能?!感谢您的帮助——我在这方面的经验不足让我发疯了。

【问题讨论】:

  • 在css url的开头添加/。

标签: html css wordpress wordpress-theming


【解决方案1】:

您正在使用相对 URL 链接到您的样式表:

<link rel="stylesheet" href="wp-content/themes/sundry/style.css" />

将其更改为绝对 URL:

<link rel="stylesheet" href="/wp-content/themes/sundry/style.css" />
                             ^

或使用get_stylesheet

【讨论】:

  • 非常感谢@Joseph-Silber!!
猜你喜欢
  • 2021-12-03
  • 2017-09-11
  • 1970-01-01
  • 1970-01-01
  • 2020-09-08
  • 2019-06-10
  • 1970-01-01
  • 2013-11-10
  • 1970-01-01
相关资源
最近更新 更多