我创建了一个插件和自定义CSS页面,在WordPress网站的一个页面上显示自定义导航菜单。我试图在感兴趣的页面上使用自定义HTML块显示导航菜单。使用查询监视器,我可以看到样式正在应用于页面,但自定义HTML从未将样式应用于页面。有人能看出我做错了什么吗?
下面是让我的CSS排队的PHP:
function additional_stylesheets() {
// wp_register_style( \'bt-wp-styles\', get_template_directory_uri().\'/bt-wp-styles.css\' );
wp_register_style( \'bt-wp-styles\', plugin_dir_path( __FILE__ ).\'css/bt-wp-styles.css\' );
wp_enqueue_style( \'bt-wp-styles\' );
}
add_action( \'wp_enqueue_scripts\', \'additional_stylesheets\' );
我的自定义CSS:
/* bt-wp-nav */
.bt-wp-nav-menu,.bt-wp-nav-menu ul,.bt-wp-nav-menu li,.bt-wp-nav-menu a { margin: 0; padding: 0; line-height: normal; list-style: none; display: block; position: relative; }
.bt-wp-nav-menu ul { opacity: 0; position: absolute; top: 100%; left: -9999px; z-index: 999; -webkit-transition: opacity .3s; transition: opacity .3s; }
.bt-wp-nav-menu li:hover > ul { left: 0; opacity: 1; z-index: 1000; }
.bt-wp-nav-menu ul li:hover > ul { top: 0; left: 100%; }
.bt-wp-nav-menu li { cursor: default; float: left; white-space: nowrap; }
.bt-wp-nav-menu ul li { float: none; }
/* sub width */
.bt-wp-nav-menu ul { min-width: 12em; -webkit-box-shadow: 2px 2px 2px rgba(0,0,0,0.25); box-shadow: 2px 2px 2px rgba(0,0,0,0.25); }
/* center */
.bt-wp-nav-center { float: right; right: 50%; }
.bt-wp-nav-center > li { left: 50%; }
/* root */
.bt-wp-nav-menu a {
padding: 0 10px;
color: #5BC0DE;
font-weight: normal;
font-size: 16px;
line-height: 40px;
text-decoration: none;
}
/* root: active */
.bt-wp-nav-menu > li > .bt-wp-nav-active { background-color: rgba(0,0,0,0.05); }
/* root: hover/persistence */
.bt-wp-nav-menu a:hover,.bt-wp-nav-menu a:focus,.bt-wp-nav-menu li:hover a {
background: #555;
color: #FFF;
}
/* 2 */
.bt-wp-nav-menu li li a,.bt-wp-nav-menu li:hover li a {
padding: 8px 10px;
background: #555;
color: #FFF;
font-size: 12px;
line-height: normal;
}
/* 2: hover/persistence */
.bt-wp-nav-menu li:hover li a:hover,.bt-wp-nav-menu li:hover li a:focus,.bt-wp-nav-menu li:hover li:hover a {
background: #444;
}
/* 3 */
.bt-wp-nav-menu li:hover li:hover li a {
background: #444;
}
/* 3: hover/persistence */
.bt-wp-nav-menu li:hover li:hover li a:hover,.bt-wp-nav-menu li:hover li:hover li a:focus,.bt-wp-nav-menu li:hover li:hover li:hover a {
background: #333;
}
/* 4 */
.bt-wp-nav-menu li:hover li:hover li:hover li a {
background: #333;
}
/* 4: hover */
.bt-wp-nav-menu li:hover li:hover li:hover li a:hover,.bt-wp-nav-menu li:hover li:hover li:hover li a:focus {
background: #222;
}
/* vertical */
.bt-wp-nav-vertical { max-width: 220px; }
.bt-wp-nav-vertical ul { top: 0; left: -9999px; }
.bt-wp-nav-vertical li { width: 100%; float: none; }
.bt-wp-nav-vertical li:hover > ul { left: 100%; }
以及我试图加载到页面上的自定义HTML片段:
<nav>
<ul class="bt-wp-nav-menu bt-wp-nav-center">
<li><a href="#">Nav Link</a></li>
<li><a href="#" class="bt-wp-nav-active">Nav Link</a>
<ul>
<li><a href="#">Sub Nav Link</a></li>
<li><a href="#">Sub Nav Link</a>
<ul>
<li><a href="#">Sub Sub Nav Link</a></li>
<li><a href="#">Sub Sub Nav Link</a></li>
<li><a href="#">Sub Sub Nav Link</a></li>
</ul>
</li>
<li><a href="#">Sub Nav Link</a></li>
<li><a href="#">Sub Nav Link</a></li>
</ul>
</li>
<li><a href="#">Nav Link</a></li>
<li><a href="#">Nav Link</a></li>
<li><a href="#">Nav Link</a></li>
</ul>
</nav>
任何帮助都将不胜感激!谢谢
布莱恩