我正在尝试使用全屏导航覆盖来处理iPad尺寸等。我正在使用bootstrap 3,我想要的是当用户获得汉堡菜单时,他们点击它,它会导致完整屏幕叠加,例如这个例子: 这里 Link
我出于某种原因无法让它处理我的代码,我想知道它是否因为我的引导类或什么?
HTML:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<nav class="navbar navbar-default navbar-fixed-top " id="section1">
<div class="container">
<div class="navbar-header">
<button class="navbar-toggle" data-target="#myNavbar" data-toggle="collapse" type="button">
<span class="icon-bar"></span> <span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand"><img alt="" src="Images/logo.png" class="img-responsive"></a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav navbar-right">
<li>
<a href="#section1">Home</a>
</li>
<li>
<a href="#section2">About Me</a>
</li>
<li>
<a href="#section3">Skills</a>
</li>
<li>
<a href="#section4">Me</a>
</li>
<li>
<a href="#section5">Hobbies</a>
</li>
<li>
<a href="#section6">Contact Me</a>
</li>
</ul>
</div>
</div>
</nav>
我想知道是否有人可以帮助我在768屏幕上使用iPad尺寸时让它工作。
答案 0 :(得分:0)
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/bootstrap.css">
<link href="css/style.css" rel="stylesheet">
<style>
.overlay {
width: 100%;
position: fixed;
z-index: 1;
top: 0;
left: 0;
background-color: rgb(0, 0, 0);
background-color: rgba(0, 0, 0, 0.9);
overflow-y: hidden;
transition: 0.5s;
}
.overlay-content {
position: relative;
top: 25%;
width: 100%;
text-align: center;
margin-top: 30px;
}
.overlay a {
padding: 8px;
text-decoration: none;
font-size: 36px;
color: #818181;
display: block;
transition: 0.3s;
}
.overlay a:hover,
.overlay a:focus {
color: #f1f1f1;
}
.overlay .closebtn {
position: absolute;
top: 20px;
right: 45px;
font-size: 60px;
}
</style>
</head>
<body>
<nav class="navbar navbar-default navbar-fixed-top " id="section1">
<div class="container">
<div class="navbar-header">
<button class="navbar-toggle" data-target="#myNavbar" data-toggle="collapse" type="button">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand">
<img alt="" src="Images/logo.png" class="img-responsive">
</a>
</div>
<div class="collapse navbar-collapse overlay" id="myNavbar">
<a href="javascript:void(0)" class="closebtn">×</a>
<ul class="nav navbar-nav navbar-right overlay-content">
<li>
<a href="#section1">Home</a>
</li>
<li>
<a href="#section2">About Me</a>
</li>
<li>
<a href="#section3">Skills</a>
</li>
<li>
<a href="#section4">Me</a>
</li>
<li>
<a href="#section5">Hobbies</a>
</li>
<li>
<a href="#section6">Contact Me</a>
</li>
</ul>
</div>
</div>
</nav>
<script src="js/jquery-2.2.3.min.js"></script>
<script src="js/bootstrap.js"></script>
<script>
$("button").on("click", function () {
$("#myNavbar").css("height", "100%");
});
$("#myNavbar a").on("click", function () {
$("#myNavbar").css("height", "0%");
})
</script>
</body>
</html>
尝试将此保存作为HTML文件并正确链接引导程序文件。你错过的东西是叠加。我在您的链接中使用了相同的叠加层。