这是我希望在 WP 2014 主题中看到的结果:
http://codepen.io/Paulie-D/pen/ekKru
我尝试通过将以下 js 文件和 css 代码添加到我的子主题来应用相同的内容:
jQuery(document).ready(function($){
jQuery(window).bind('scroll', function($) {
var distance = 50;
if ($(window).scrollTop() > distance) {
$('header').addClass('scrolled');
}
else {
$('header').removeClass('scrolled');
}
});
});
.scrolled {
background: #bada55;
}
此外,我在子主题的functions.php中添加了以下内容:
function my_custommenu_tf_child() {
if (!is_admin()) {
if (is_front_page()) {
wp_enqueue_script( 'my_Custommenu', get_stylesheet_directory_uri() . '/js/mycustommenu.js', '', '1.0', true );
}
}
}
add_action('wp_enqueue_scripts', 'my_custommenu_tf_child');
并没有真正起作用...我不是专业的开发人员,因此如果您可以插入正确的代码,以便我可以比较并查看到底出了什么问题,我将不胜感激,而不是引用可能的解决方案。谢谢!
最佳答案
.js
文件中是否有以下代码?
.scrolled {
背景:#bada55;
}
如果有,您需要将其移动到某个 .css
文件,并将其链接到您的functions.php
关于javascript - 在 WordPress 21 中更改滚动条上的标题背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39767398/