我无法使用非画布导航设计修复元素。 http://codepen.io/StuffieStephie/pen/wajxXa
(调整视口大小以使其小于1000px,否则标题不可见。) 在桌面样式中,导航栏是固定的,但在移动设备中,即使我有一个!重要的声明,标题也不是
$(".toggle-nav").click(function() {
// Calling a function in case you want to expand upon this.
toggleNav();
});
function toggleNav() {
if ($('#drawer').hasClass('show-nav')) {
$('#drawer').removeClass('show-nav');
$('#nav-icon').removeClass('open');
} else {
$('#drawer').addClass('show-nav');
$('#nav-icon').addClass('open');
}
}
$('#closeButton').click(function() {
$('#drawer').removeClass('show-nav');
$('#nav-icon').removeClass('open');
});
$("nav h3").click(function(){
$("nav ul ul").slideUp();
if(!$(this).next().is(":visible"))
{
$(this).next().slideDown();
}
});
$("#downSplashArrow").click(function(event) {
event.preventDefault();
if ($('header').is(":visible")) {
$('#site-canvas').animate({
scrollTop: $("#page-content").offset().top
}, 1000); } else {
$('body').animate({
scrollTop: $("#page-content").offset().top
}, 1000);
}
}
);

/* Import custom fonts */
@import url(http://fonts.googleapis.com/css?family=Montserrat:400,700);
/* Reset Default Browser Styles */
html, body, a, h1, h2, h3, h4, h5, h6, ul, li, span {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
text-decoration: none;
list-style-type: none;
color: inherit;
}
html,
body {
height: 100%;
/*overflow: hidden;*/
}
/* Navagation */
nav {
width: 100%;
font-family: Montserrat, 'Montserrat-Regular', 'Montserrat-Regular-eot', sans-serif;
font-weight: 700;
background: #333;
height: 55px;
text-align: center;
position: fixed;
z-index: 10;
font-size: .8em;
text-transform: uppercase;
}
/*
nav img {
height: 100%;
vertical-align:middle;
margin-right: 50px;
display: inline;
} */
header, #closeButton {
display: none;
}
nav ul li {
/*width: 11%;
min-width: 140px; */
color: #DDD;
float: left;
display: inline-block;
}
nav li a{
display: inline-block;
line-height: 55px;
padding: 0 5px 0 20px;
}
nav li ul{
display: none;
width: 200px;
position: absolute;
font-size: .8em;
}
nav li:hover {
color: #3C6DDF;
background-color: #8db3ff;
}
nav li li a {
line-height: 1em;
padding: 20px 0;
width: 200px;
background: #333333;
}
nav li li a:hover {
background-color: #8db3ff; }
nav li span {
font-weight:900;
padding: 0 0px 0 .5em;
cursor:pointer;
}
#site-canvas {
width: 100%;
height: 100%;
/*overflow-y: scroll;*/
}
/* Splash page */
.splash {
background: url('http://netdna.webdesignerdepot.com/uploads7/how-to-create-a-scrollable-splash-screen-with-css3-and-jquery/img/splash-bg.jpg') center center;
background-size: cover;
min-height: 100%;
width: 100%;
background-size: cover;
min-height: 100%;
width: 100%;
text-align: center;
position:relative;
/*
position:absolute;
top: 0;
left: 0;
z-index: 0;
*/
}
a.splash-arrow {
color: white;
font-size: 1.2em;
position: absolute;
bottom: 55px;
left: 50%;
margin-left: -25px;
padding: 10px;
width: 50px;
height: 50px;
font-weight: bold;
-webkit-transition: all 0.1s ease;
-moz-transition: all 0.1s ease;
-o-transition: all 0.1s ease;
transition: all 0.1s ease;
-webkit-animation-delay: 1.5s;
-moz-animation-delay: 1.5s;
animation-delay: 1.5s;
border: 3px solid white;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border-radius: 50%;
}
.splash-arrow img {
margin-top: 40%;
}
a.splash-arrow:hover {
text-decoration: none;
bottom: 50px;
}
@media screen and (max-width: 949px) {
#closeButton {
display: block;
line-height: 55px;
border-bottom: none;
}
html,
body {
height: 100%;
overflow: hidden;
}
/* Mobile Slideout */
#drawer {
min-width: 200px;
position: absolute;
top: 0;
left: -300px;
height: 100%;
width: 300px;
background: #2f2f2f;
overflow-x: hidden;
overflow-y: auto;
-webkit-overflow-scrolling: touch;
-webkit-transform: translateX(0);
transform: translateX(0);
-webkit-transition: .3s ease all;
transition: .3s ease all;
}
#site-canvas {
width: 100%;
height: 100%;
overflow-x: hidden;
overflow-y: scroll;
-webkit-transform: translateX(0);
transform: translateX(0);
-webkit-transition: .3s ease all;
transition: .3s ease all;
position: relative;
}
header {
width: 100%;
display: block;
top: 0px;
left: 0px;
right: 0px;
height: 55px;
position: fixed !important;
background: #333;
z-index: 1;
-webkit-transform: translateX(0);
transform: translateX(0);
-webkit-transition: .3s ease all;
transition: .3s ease all;
}
/* Show-nav styles */
#drawer.show-nav, #drawer.show-nav + #site-canvas {
-webkit-transform: translateX(300px);
transform: translateX(300px);
}
#drawer.show-nav + #site-canvas {
background: rgba(255, 255, 255, .8);
height: 100%;
}
/*General Navagation*/
nav {
font-family: Montserrat, 'Montserrat-Regular', 'Montserrat-Regular-eot', sans-serif;
font-weight: 700;
background: #333;
height: 55px;
text-align:center;
font-size: .8em;
text-transform: uppercase;
position: absolute;
z-index: 11;
}
nav h3 {
font-size: 2em;
background: #283744;
border-bottom: 1px solid #DDD;;
cursor: pointer;
}
#closeButton {
background: #333;
}
nav ul ul {
display: none;
}
nav ul li {
/*width: 11%;
min-width: 140px; */
color: #DDD;
float: none;
display: block;
}
nav li ul{
width: 100%;
position: relative;
}
nav li ul li a {
width: 100%
}
/* Icon 1 */
#nav-icon {
width: 60px;
height: 45px;
position: relative;
margin-left: 10px;
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-o-transform: rotate(0deg);
transform: rotate(0deg);
-webkit-transition: .5s ease-in-out;
-moz-transition: .5s ease-in-out;
-o-transition: .5s ease-in-out;
transition: .5s ease-in-out;
cursor: pointer;
display: inline-block;
}
#nav-icon span {
display: block;
position: absolute;
height: 9px;
width: 100%;
background: rgb(145, 16, 20);
border-radius: 9px;
opacity: 1;
left: 0;
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-o-transform: rotate(0deg);
transform: rotate(0deg);
-webkit-transition: .25s ease-in-out;
-moz-transition: .25s ease-in-out;
-o-transition: .25s ease-in-out;
transition: .25s ease-in-out;
}
/* Menu Icon*/
#nav-icon span:nth-child(1) {
top: 0px;
-webkit-transform-origin: left center;
-moz-transform-origin: left center;
-o-transform-origin: left center;
transform-origin: left center;
}
#nav-icon span:nth-child(2) {
top: 18px;
-webkit-transform-origin: left center;
-moz-transform-origin: left center;
-o-transform-origin: left center;
transform-origin: left center;
}
#nav-icon span:nth-child(3) {
top: 36px;
-webkit-transform-origin: left center;
-moz-transform-origin: left center;
-o-transform-origin: left center;
transform-origin: left center;
}
#nav-icon.open span:nth-child(1) {
-webkit-transform: translate(8px,-4px) rotate(45deg);
-moz-transform: translate(8px,-4px) rotate(45deg);
-o-transform: translate(8px,-4px) rotate(45deg);
transform: translate(8px,-4px) rotate(45deg);
}
#nav-icon.open span:nth-child(2) {
width: 0%;
opacity: 0;
}
#nav-icon.open span:nth-child(3) {
-webkit-transform: translate(8px,2px) rotate(-45deg);
-moz-transform: translate(8px,2px) rotate(-45deg);
-o-transform: translate(8px,2px) rotate(-45deg);
transform: translate(8px,2px) rotate(-45deg);
//top: 39px;
//left: 8px;
}
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<html>
<head>
<!-- Meta -->
<meta charset="utf-8">
<title>Off Canvas Menus Demo</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Favicon -->
<!-- Styles -->
<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css">
<!--[if lt IE 9]><script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
</head>
<body>
<nav id="drawer">
<ul>
<h3 id="closeButton"><li><i class="fa fa-times-circle-o"></i> Close <i class="fa fa-times-circle-o"></i></li></h3>
<li>
<h3><a href="#" title="Our Event Home Page">Home</a></h3></li>
<li>
<h3><a href="#" id="events">Events <span>+</span></a></h3>
<ul id="eventsMenu" class="subMenu">
<li><a href="#">Some Contest</a></li>
<li><a href="#">Another Contest</a></li>
<li><a href="#">Misc. Events</a></li>
<li><a href="#">Dance</a></li>
<li><a href="#">Concert</a></li>
<li><a href="#">An event with a fairly long title</a></li>
</ul>
</li>
<li class="cssHover topMain">
<h3><a href="#" id="rooms">Rooms <span>+</span></a></h3>
<ul id ="roomsMenu" class="subMenu">
<li><a href="#">Art Gallery</a></li>
<li><a href="#">Market Room</a></li>
<li><a href="#">Some other room</a></li>
<li><a href="#">Film Screening</a></li>
<li><a href="#">Gaming</a></li>
<li><a href="#">Our Shop</a></li>
</ul>
</li>
<li class="topMain">
<h3> <a href="#">Special Guests</a> </h3> </li>
<li class="cssHover topMain">
<h3><a href="#" id="info">Information <span>+</span></a></h3>
<ul id="infoMenu" class="subMenu">
<li><a href="#">Parents Info</a></li>
<li><a href="#">Our Policies</a></li>
<li><a href="#">Maps / Location</a></li>
<li><a href="#">Need a Hotel?</a></li>
</ul>
</li>
<li class="cssHover topMain">
<h3><a href="#" id="story">History <span>+</span></a></h3>
<ul id="storyMenu" class="subMenu">
<li><a href="#">Previous Festivals</a></li>
<li><a href="#">Meet the Staff</a></li>
<li><a href="#">Artwork</a></li>
</ul>
</li>
<li class="cssHover topMain">
<h3><a href="#" id="contact">Contact Us <span>+</span></a></h3>
<ul id="contactMenu" class="subMenu">
<li><a href="#">Contact the Staff</a></li>
<li><a href="#">Volunteer</a></li>
<li><a href="#">Submit an Idea</a></li>
<li><a href="#">Advertise Our Event</a></li>
</ul>
</li>
<li class="topMain"><h3><a href="#">Registration</a></h3></li>
</ul>
</nav>
<!-- End Menu -->
<div id="site-canvas">
<header>
<a href="#" class="toggle-nav" ><div id="nav-icon">
<span></span>
<span></span>
<span></span>
</div></a> <img src="http://www.wpclipart.com/blanks/buttons/glossy_buttons/glossy_button_blank_red_rectangle_T.png" height="50"></header>
<div class="splash">
<a href="#" id="downSplashArrow" class="splash-arrow"><img src="http://netdna.webdesignerdepot.com/uploads7/how-to-create-a-scrollable-splash-screen-with-css3-and-jquery/img/down-arrow.png"></a>
</div>
<div id="page-content">
<p>TEXT BEGINS HERE Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam tincidunt congue sapien, eu fermentum elit sollicitudin sit amet. Nulla quam est, tincidunt sed risus id, interdum elementum velit. Curabitur a varius justo, eget pharetra urna. Maecenas at tincidunt purus. Quisque dignissim sagittis nunc, quis commodo justo efficitur a. Nam congue felis vel est mollis, vitae tristique libero viverra. Nulla cursus, sapien sed mattis maximus, ligula tellus dapibus diam, in vulputate erat lorem ut neque. Suspendisse scelerisque eros enim, id lobortis lacus maximus eu. Aliquam augue ipsum, mattis et suscipit vel, facilisis vitae ipsum. Praesent semper magna ligula, id molestie eros tempus vitae.
Nullam eu quam quis nibh sodales fringilla. Vivamus molestie fermentum urna nec ultricies. Mauris ut convallis ligula, sit amet laoreet nulla. Mauris pellentesque elit nec risus laoreet, elementum faucibus erat vulputate. Curabitur consectetur, lacus aliquam iaculis finibus, metus metus porta metus, vitae bibendum mi ante porttitor lectus. Aliquam dui felis, auctor ut aliquet pellentesque, dignissim in nisl. Phasellus finibus finibus ante id vulputate. Suspendisse a ipsum blandit tortor rhoncus tincidunt eu ut tortor.
Aenean convallis quam id tortor tincidunt, eu rutrum lectus ultricies. Aenean aliquet in velit luctus porta. Phasellus nec urna volutpat, posuere purus at, euismod nulla. Maecenas sed accumsan libero. Duis efficitur porttitor elit, sed commodo leo mattis eu. Aenean sit amet dui euismod, finibus lectus non, fermentum quam. Morbi vel rutrum quam, non iaculis ipsum. Vestibulum rutrum justo at consequat euismod. Sed feugiat nec velit ac laoreet. Etiam elit tellus, posuere in semper id, porta ut purus. Vestibulum sagittis id risus ut finibus. Morbi sagittis mattis tempor. Maecenas bibendum egestas rhoncus. Nulla facilisi.
Integer eleifend, nibh in molestie blandit, tortor turpis finibus risus, ut pellentesque odio magna a nisl. Integer porttitor congue semper. Cras vulputate, tortor non iaculis elementum, massa velit convallis ipsum, a varius nisl nunc vel nisi. Nam accumsan eros eget augue varius, ac interdum tellus pretium. Morbi malesuada lectus quis elit blandit volutpat. Duis odio erat, fermentum id nibh facilisis, fringilla congue urna. Sed scelerisque nunc ac ante varius, eget vulputate urna dictum. Proin vel pulvinar velit, sed faucibus orci.
Integer varius nisi eget egestas convallis. In eget elit pharetra, posuere nisi a, convallis nulla. Etiam volutpat magna sit amet pharetra volutpat. Aliquam sed orci viverra, mattis nibh sit amet, mollis ante. Morbi elementum diam neque, quis ultrices quam dignissim non. Phasellus tincidunt tincidunt nisi. Vestibulum commodo diam lorem, id vulputate felis lacinia nec.
</p> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam tincidunt congue sapien, eu fermentum elit sollicitudin sit amet. Nulla quam est, tincidunt sed risus id, interdum elementum velit. Curabitur a varius justo, eget pharetra urna. Maecenas at tincidunt purus. Quisque dignissim sagittis nunc, quis commodo justo efficitur a. Nam congue felis vel est mollis, vitae tristique libero viverra. Nulla cursus, sapien sed mattis maximus, ligula tellus dapibus diam, in vulputate erat lorem ut neque. Suspendisse scelerisque eros enim, id lobortis lacus maximus eu. Aliquam augue ipsum, mattis et suscipit vel, facilisis vitae ipsum. Praesent semper magna ligula, id molestie eros tempus vitae.
Nullam eu quam quis nibh sodales fringilla. Vivamus molestie fermentum urna nec ultricies. Mauris ut convallis ligula, sit amet laoreet nulla. Mauris pellentesque elit nec risus laoreet, elementum faucibus erat vulputate. Curabitur consectetur, lacus aliquam iaculis finibus, metus metus porta metus, vitae bibendum mi ante porttitor lectus. Aliquam dui felis, auctor ut aliquet pellentesque, dignissim in nisl. Phasellus finibus finibus ante id vulputate. Suspendisse a ipsum blandit tortor rhoncus tincidunt eu ut tortor.
Aenean convallis quam id tortor tincidunt, eu rutrum lectus ultricies. Aenean aliquet in velit luctus porta. Phasellus nec urna volutpat, posuere purus at, euismod nulla. Maecenas sed accumsan libero. Duis efficitur porttitor elit, sed commodo leo mattis eu. Aenean sit amet dui euismod, finibus lectus non, fermentum quam. Morbi vel rutrum quam, non iaculis ipsum. Vestibulum rutrum justo at consequat euismod. Sed feugiat nec velit ac laoreet. Etiam elit tellus, posuere in semper id, porta ut purus. Vestibulum sagittis id risus ut finibus. Morbi sagittis mattis tempor. Maecenas bibendum egestas rhoncus. Nulla facilisi.
Integer eleifend, nibh in molestie blandit, tortor turpis finibus risus, ut pellentesque odio magna a nisl. Integer porttitor congue semper. Cras vulputate, tortor non iaculis elementum, massa velit convallis ipsum, a varius nisl nunc vel nisi. Nam accumsan eros eget augue varius, ac interdum tellus pretium. Morbi malesuada lectus quis elit blandit volutpat. Duis odio erat, fermentum id nibh facilisis, fringilla congue urna. Sed scelerisque nunc ac ante varius, eget vulputate urna dictum. Proin vel pulvinar velit, sed faucibus orci.
Integer varius nisi eget egestas convallis. In eget elit pharetra, posuere nisi a, convallis nulla. Etiam volutpat magna sit amet pharetra volutpat. Aliquam sed orci viverra, mattis nibh sit amet, mollis ante. Morbi elementum diam neque, quis ultrices quam dignissim non. Phasellus tincidunt tincidunt nisi. Vestibulum commodo diam lorem, id vulputate felis lacinia nec.
</p> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam tincidunt congue sapien, eu fermentum elit sollicitudin sit amet. Nulla quam est, tincidunt sed risus id, interdum elementum velit. Curabitur a varius justo, eget pharetra urna. Maecenas at tincidunt purus. Quisque dignissim sagittis nunc, quis commodo justo efficitur a. Nam congue felis vel est mollis, vitae tristique libero viverra. Nulla cursus, sapien sed mattis maximus, ligula tellus dapibus diam, in vulputate erat lorem ut neque. Suspendisse scelerisque eros enim, id lobortis lacus maximus eu. Aliquam augue ipsum, mattis et suscipit vel, facilisis vitae ipsum. Praesent semper magna ligula, id molestie eros tempus vitae.
Nullam eu quam quis nibh sodales fringilla. Vivamus molestie fermentum urna nec ultricies. Mauris ut convallis ligula, sit amet laoreet nulla. Mauris pellentesque elit nec risus laoreet, elementum faucibus erat vulputate. Curabitur consectetur, lacus aliquam iaculis finibus, metus metus porta metus, vitae bibendum mi ante porttitor lectus. Aliquam dui felis, auctor ut aliquet pellentesque, dignissim in nisl. Phasellus finibus finibus ante id vulputate. Suspendisse a ipsum blandit tortor rhoncus tincidunt eu ut tortor.
Aenean convallis quam id tortor tincidunt, eu rutrum lectus ultricies. Aenean aliquet in velit luctus porta. Phasellus nec urna volutpat, posuere purus at, euismod nulla. Maecenas sed accumsan libero. Duis efficitur porttitor elit, sed commodo leo mattis eu. Aenean sit amet dui euismod, finibus lectus non, fermentum quam. Morbi vel rutrum quam, non iaculis ipsum. Vestibulum rutrum justo at consequat euismod. Sed feugiat nec velit ac laoreet. Etiam elit tellus, posuere in semper id, porta ut purus. Vestibulum sagittis id risus ut finibus. Morbi sagittis mattis tempor. Maecenas bibendum egestas rhoncus. Nulla facilisi.
Integer eleifend, nibh in molestie blandit, tortor turpis finibus risus, ut pellentesque odio magna a nisl. Integer porttitor congue semper. Cras vulputate, tortor non iaculis elementum, massa velit convallis ipsum, a varius nisl nunc vel nisi. Nam accumsan eros eget augue varius, ac interdum tellus pretium. Morbi malesuada lectus quis elit blandit volutpat. Duis odio erat, fermentum id nibh facilisis, fringilla congue urna. Sed scelerisque nunc ac ante varius, eget vulputate urna dictum. Proin vel pulvinar velit, sed faucibus orci.
Integer varius nisi eget egestas convallis. In eget elit pharetra, posuere nisi a, convallis nulla. Etiam volutpat magna sit amet pharetra volutpat. Aliquam sed orci viverra, mattis nibh sit amet, mollis ante. Morbi elementum diam neque, quis ultrices quam dignissim non. Phasellus tincidunt tincidunt nisi. Vestibulum commodo diam lorem, id vulputate felis lacinia nec.
</p>.
</div> <!-- #page-content -->
</div><!-- #site-canvas -->
</body>
</html>
&#13;
当画布上的菜单抽屉打开时,标题需要与画布的其余部分一起滑过这一事实,这有点令人费解。
有什么想法吗?
编辑:嗯,我发现了一些令人不安的问题,我的jQuery向下滚动功能(桌面版)在Chrome中运行,但在Firefox和IE中无效!在IE中,我的标题已修复,但在Chrome和Firefox中没有。这是什么ಠ_ಠ
答案 0 :(得分:1)
试试这个:
将您的<header>
移到#site-canvas
之外的HTML中。所以你的HTML结构看起来像这样:
<body>
<nav>
<header>
<#site-nav>
然后将其添加到您的CSS
nav.show-nav ~ header{
transform: translateX(300px);
}
接下来更改此CSS选择器:
#drawer.show-nav, #drawer.show-nav + #site-canvas
到此:
#drawer.show-nav, #site-canvas.slide
现在在这里切换新的slide
课程:
$(".toggle-nav").click(function() {
// Calling a function in case you want to expand upon this.
$('#site-canvas').toggleClass('slide');
toggleNav();
});
我还会将padding-top:55px;
添加到#site-canvas
,以便为您的固定标题提供空间。
请参阅此更新CodePen。