【发布时间】:2013-12-04 04:55:08
【问题描述】:
我正在使用 Bootstrap v3.0.2 开发响应式 wordpress 主题。
在移动/平板电脑浏览器而不是整个菜单中,我需要显示 Bootstrap 切换按钮。我的按钮正在显示,但是当我单击它时,什么也没有发生。这是我在header.php 中写的代码:
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
还有我在function.php 写的那一篇:
function wpt_register_js() {
wp_register_script(
'jquery.bootstrap.min',
get_template_directory_uri() . '/js/bootstrap.min.js',
'jquery'
);
wp_enqueue_script('jquery.bootstrap.min');
}
add_action( 'init', 'wpt_register_js' );
function wpt_register_css() {
wp_register_style(
'bootstrap.min',
get_template_directory_uri() . '/css/bootstrap.min.css'
);
wp_enqueue_style( 'bootstrap.min' );
}
add_action( 'wp_enqueue_scripts', 'wpt_register_css' );
footer.php 代码包含:
<script src="https://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<?php wp_footer();?>
</body>
header.php 包含:
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?php wp_title('|', true, 'right'); ?></title>
<link href="<?php echo get_template_directory_uri(); ?>/css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link href="<?php echo get_template_directory_uri(); ?>/css/style.css" rel="stylesheet" type="text/css">
<?php wp_head(); ?>
</head>
这个问题通过 Bass Jobsen 的回答解决了。谢谢朋友
【问题讨论】:
-
给出的答案将解决您的问题,如果仍然存在,请分享有问题的网址
标签: twitter-bootstrap wordpress-theming twitter-bootstrap-3 collapse togglebutton