【问题标题】:Genesis Framework - How to change custom header css code?Genesis Framework - 如何更改自定义标头 css 代码?
【发布时间】:2014-09-04 17:29:59
【问题描述】:

我正在使用 genesis 框架,我想在我的子主题中支持标题图像。我想将我上传的图像的位置更改为标题图像。

我在我的functions.php中添加了这行代码:

add_theme_support( 'genesis-custom-header', array( 'width' => 213, 'height' => 300) );

Genesis 现在为首页中的 .site-header 生成 css 代码:

.site-header { background: url(http://localhost:8888/studio/wp-content/uploads/2014/09/my_logo.png) no-repeat !important; }

我想更改此代码,因为我想将一些其他 CSS 内容应用于我的 <header>,例如 background-positionbackground-size 等。我在官方文档中看到我可以在 add_theme_support 中使用 'header-callback',但它是如何工作的呢?我如何编写我的回调函数,WP 会自动更改上面为.site-header 生成的代码?

如果我在我的style.css 文件中更改.site-header,它不会改变任何内容。必须如上生成,但是如何生成呢?

谢谢!

【问题讨论】:

    标签: php css wordpress genesis


    【解决方案1】:

    用 style.css 编写的 CSS 应该覆盖默认样式!你确定加价是一样的吗?

    您可以尝试在 css 值中使用 '!important' 声明来赋予优先级,例如

    .site-header {
        background-size: cover !important;
    }
    

    此外,您可以向自定义标头数组添加更多值:

    add_theme_support( 'genesis-custom-header', array(
        'default-image' => get_stylesheet_directory_uri() . '/images/logo.png',
        'default-color' => 'efefe9',
        'header_image'    => '',
        'header-selector' => '.site-title a',
        'header-text'     => false,
        'height'          => 115,
        'width'           => 960,
    ) );
    

    并使用以下方式设置您的徽标样式:

    .site-header .site-title a {
         //your css here
    }
    

    请注意,如果您使用的是子主题(我认为),则此 sn-p 有效

    希望它有所帮助;) 弗朗切斯科

    【讨论】:

      猜你喜欢
      • 2014-05-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多