我正在尝试将此模式添加到我现有的HTML页面中。
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" style="height: 100vh !important">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-body" style="height: 100vh; opacity:1">
<button type="button" class="close" data-dismiss="modal" >×</button>
<ul class="nav navbar-nav navbar-right hidden-lg hidden-md" >
<li><a href="#myPage">HOME1</a></li>
<li><a href="#band">BAND1</a></li>
<li><a href="#tour">TOUR1</a></li>
<li><a href="#contact">CONTACT</a></li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">MORE
<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#">Merchandise</a></li>
<li><a href="#">Extras</a></li>
<li><a href="#">Media</a></li>
</ul>
</li>
<li><a href="#"><span class="glyphicon glyphicon-search"></span></a></li>
</ul>
</div>
</div>
</div>
</div>
<div class="bg-img-hero">
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myModal">
<span class="icon-bar" style="color: yellow !important"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<img src="Images\logos\flexit-logo-TM-comp.png" style="padding-top:15px" >
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav navbar-right" >
<li ><a href="HowItWorks.html" style="color: white !important">HOME</a></li>
<li><a href="#band" style="color: white !important">BAND</a></li>
<li><a href="#tour" style="color: white !important">TOUR</a></li>
<li><a href="#contact" style="color: white !important">CONTACT</a></li>
</ul>
</div>
<div class="collapse navbar-collapse" id="myNavbar1">
<ul class="nav navbar-nav navbar-right hidden-lg hidden-md" >
<li><a href="HowItWorks.html">HOME1</a></li>
<li><a href="#band">BAND1</a></li>
<li><a href="#tour">TOUR1</a></li>
<li><a href="#contact">CONTACT</a></li>
</ul>
</div>
</div>
</nav>
</div>
上面的模式在W3schools演示中可以正常工作,但是当添加到我的代码中时,“ Close Modal”不起作用。我不知道为什么。预先感谢您的帮助。
答案 0 :(得分:0)
请确保将data-toggle="modal"
放在应该打开模式的按钮上。
答案 1 :(得分:-1)
检查浏览器的控制台,如果显示任何错误,请给我们解决错误,但可能是Jquery的错误,或者$()不是意味着您不包括require jquery的函数或您使用的bottstrap javascript版本不正确