我一个月前开始使用cakephp框架工作。我在制作移动响应式导航栏时遇到了麻烦。我在Cake上使用了以下Bootstrap: https://startbootstrap.com/template-overviews/round-about/
问题是单击导航栏时崩溃不会显示。
以下是相关的ctp文件:
default.thtml中
<?php$cakeDescription = 'BuySellSFSU';?>
<!DOCTYPE html>
<html>
<head>
<?= $this->Html->charset() ?>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
<?= $cakeDescription ?>:
<?= $this->fetch('title') ?>
</title>
<?= $this->Html->meta('icon') ?>
<?= $this->Html->css('bootstrap.css') ?>
<?= $this->Html->css('bootstrap.min.css') ?>
<?= $this->Html->css('round-about.css') ?>
<?= $this->Html->script('bootstrap.js') ?>
<?= $this->Html->script('bootstrap.min.js') ?>
<?= $this->Html->script('jquery.js') ?>
<?= $this->Html->script('custom.js') ?>
<?= $this->fetch('meta') ?>
<?= $this->fetch('css') ?>
<?= $this->fetch('script') ?>
</head>
<body>
<!-- Navigation -->
<?= $this->element('header') ?>
<div id="content" class="container">
<?= $this->Flash->render() ?>
<?= $this->fetch('content') ?>
<hr>
<!-- Footer -->
<?= $this->element('footer') ?>
</div>
</body>
</html>
header.ctp
<!-- Navigation -->
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">BuySellStuffs</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li>
<?php echo $this->Html->link('About', array('controller'=>'pages', 'action'=>'home', 'full_base'=>true)); ?>
</li>
<li>
<a href="#">Services</a>
</li>
<li>
<a href="#">Contact</a>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container -->
</nav>
问题又头疼lol
感谢您的帮助,真的很感激。 :d
答案 0 :(得分:1)
更改bootstrap.min.js和jquery.js命令,不要同时包含bootstrap.min.js和bootstrap.js,只使用一个。
在Bootstrap js之前加载Jquery:
<?= $this->Html->script('jquery.js') ?>
<?= $this->Html->script('bootstrap.min.js') ?>
答案 1 :(得分:1)
尝试在bootstrap之前加载jquery并删除bootstrap.min(css和js)
<?= $this->Html->script('custom.js') ?>
<?= $this->Html->script('jquery.js') ?>
<?= $this->Html->script('bootstrap.js') ?>
<?= $this->Html->css('bootstrap.css') ?>
<?= $this->Html->css('round-about.css') ?>