Javascript JS按钮似乎不起作用

Javascript JS按钮似乎不起作用,javascript,jquery,Javascript,Jquery,为什么我的导航菜单滑块按钮不工作? 我已经包括了Jquery。。有人能指出我的错误吗 没有jquery cdn的代码示例来自 另外,如何创建右滑块选项卡的另一个版本?我觉得很简单?复制粘贴和更改变量 <!DOCTYPE html> <html> <head> <link rel="stylesheet" type="text/css" href="style.css"> </head> <

为什么我的导航菜单滑块按钮不工作? 我已经包括了Jquery。。有人能指出我的错误吗

没有jquery cdn的代码示例来自

另外,如何创建右滑块选项卡的另一个版本?我觉得很简单?复制粘贴和更改变量

<!DOCTYPE html>
<html>
    <head>
        <link rel="stylesheet" type="text/css" href="style.css">
    </head>
    <body>
        <div id="navContainer">
            <ul>
                <li>Home</li>
                <li>Page 1</li>
                <li>Page 2</li>
                <li>Page 3</li>
                <li>Page 4</li>
                <li>Page 5</li>
                <li>Page 6</li>
                <li>Page 7</li>
            </ul>
            <div id="contentContainer">
                <header>
                    <div href="" onclick="openNav();" class="button"></div>
                </header>
                <div id="placeCheckHere"></div>
            </div>
        </div>              
        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
        <script>
            function closeNav() {
                $('#contentContainer').removeClass('moveOut').addClass('moveIn');
                $('#navContainer ul').removeClass('slideIn').addClass('slideOut');
                $('#placeCheckHere').html("");
            }
            function openNav() { 
                $('#contentContainer').removeClass('moveIn').addClass('moveOut');
                $('#navContainer ul').removeClass('slideOut').addClass('slideIn');
                $('#placeCheckHere').html("<div id='checkNavDiv' onclick='closeNav();'></div>");  
            }
        </script>
    </body>
</html>

  • 第1页
  • 第2页
  • 第3页
  • 第4页
  • 第5页
  • 第6页
  • 第7页
函数closeNav(){ $('#contentContainer').removeClass('moveOut').addClass('moveIn'); $('#navContainer ul').removeClass('slideIn').addClass('slideOut'); $('#placeCheckHere').html(“”); } 函数openNav(){ $('#contentContainer').removeClass('moveIn').addClass('moveOut'); $('#navContainer ul').removeClass('slideOut').addClass('slideIn'); $('#placeCheckHere').html(“”); }
我认为问题在于,您试图重现该示例,但css存在问题,即
scss
。 下面是这个例子的完整代码,同样的工作方式是相反的(大致上)

从左到右

css

* {
  padding: 0;
  margin: 0;
}

html, body {
  width: 100%;
  height: 100%;
}

body {
  font-family: 'Helvetica';
  font-weight: 300;
}

#navContainer {
  width: 85%;
  height: 100%;
  padding-right: 15%;
  display: block;
  background: #222;
  position: relative;
  top: 0px;
  left: 0px;
  overflow-x: hidden;
  z-index: 1;
}

ul {
  list-style: none;
  padding: 10px;
}

li {
  padding: 10px;
  color: #eee;
}

#contentContainer {
  width: 100%;
  min-height: 100%;
  position: absolute;
  background: #ddd;
  z-index: 2;
  top: 0px;
  left: 0px;
  box-shadow: 0 0 40px black;
}

#checkNavDiv {
  width: 100%;
  height: 100%;
  display: block;
  position: absolute;
  top: 0px;
  left: 0px;
  cursor: pointer;
}

header {
  width: 100%;
  height: 50px;
  background: #bbb;
  box-shadow: 0 2px 2px rgba(0, 0, 0, 0.5);
}

.button {
  width: 33px;
  height: 24px;
  background: url("http://birdsongmedia.com/images/menu-icon1.png");
  cursor: pointer;
  position: relative;
  top: 13px;
  left: 19px;
}

article {
  padding: 10px;
}

.moveOut {
  -webkit-animation: moveContentOut 0.35s ease;
  -webkit-transform: translate(85%, 0);
}

.moveIn {
  -webkit-animation: moveContentIn 0.35s ease;
  -webkit-transform: translate(0, 0);
}

@-webkit-keyframes moveContentOut {
  0% {
    -webkit-transform: translate(0, 0);
  }

  100% {
    -webkit-transform: translate(85%, 0);
  }
}

@-webkit-keyframes moveContentIn {
  0% {
    -webkit-transform: translate(85%, 0);
  }

  100% {
    -webkit-transform: translate(0, 0);
  }
}

.slideIn {
  -webkit-animation: navSlideIn 0.35s ease;
  -webkit-transform: translate(0, 0);
}

.slideOut {
  -webkit-animation: navSlideOut 0.35s ease;
  -webkit-transform: translate(-40px, 0);
}

@-webkit-keyframes navSlideIn {
  0% {
    -webkit-transform: translate(-40px, 0);
  }

  100% {
    -webkit-transform: translate(0, 0);
  }
}

@-webkit-keyframes navSlideOut {
  0% {
    -webkit-transform: translate(0, 0);
  }

  100% {
    -webkit-transform: translate(-40px, 0);
  }
}
    * {
  padding: 0;
  margin: 0;
}

html, body {
  width: 100%;
  height: 100%;
}

body {
  font-family: 'Helvetica';
  font-weight: 300;
}

#navContainer {
  width: 85%;
  height: 100%;
  padding-right: 15%;
  display: block;
  background: #222;
  position: relative;
  top: 0px;
  left: 0px;
  overflow-x: hidden;
  z-index: 1;
}

ul {
  list-style: none;
  padding: 10px;
}

#navContainer ul {
  position: relative;
  left: 110%;
}

li {
  padding: 10px;
  color: #eee;
}

#contentContainer {
  width: 100%;
  min-height: 100%;
  position: absolute;
  background: #ddd;
  z-index: 2;
  top: 0px;
  left: 0px;
  box-shadow: 0 0 40px black;
}

#checkNavDiv {
  width: 100%;
  height: 100%;
  display: block;
  position: absolute;
  top: 0px;
  left: 0px;
  cursor: pointer;
}

header {
  width: 100%;
  height: 50px;
  background: #bbb;
  box-shadow: 0 2px 2px rgba(0, 0, 0, 0.5);
}

.button {
  width: 33px;
  height: 24px;
  background: url("http://birdsongmedia.com/images/menu-icon1.png");
  cursor: pointer;
  position: relative;
  top: 13px;
  left: -19px;
  float: right;
}

article {
  padding: 10px;
}

.moveOut {
  -webkit-animation: moveContentOut 0.35s ease;
  -webkit-transform: translate(-85%, 0);
}

.moveIn {
  -webkit-animation: moveContentIn 0.35s ease;
  -webkit-transform: translate(0, 0);
}

@-webkit-keyframes moveContentOut {
  0% {
    -webkit-transform: translate(0, 0);
  }

  100% {
    -webkit-transform: translate(-85%, 0);
  }
}

@-webkit-keyframes moveContentIn {
  0% {
    -webkit-transform: translate(-85%, 0);
  }

  100% {
    -webkit-transform: translate(0, 0);
  }
}

.slideIn {
  -webkit-animation: navSlideIn 0.35s ease;
  -webkit-transform: translate(0, 0);
}

.slideOut {
  -webkit-animation: navSlideOut 0.35s ease;
  -webkit-transform: translate(-40px, 0);
}

@-webkit-keyframes navSlideIn {
  0% {
    -webkit-transform: translate(-40px, 0);
  }

  100% {
    -webkit-transform: translate(0, 0);
  }
}

@-webkit-keyframes navSlideOut {
  0% {
    -webkit-transform: translate(0, 0);
  }

  100% {
    -webkit-transform: translate(-40px, 0);
  }
}
<div id="navContainer">
  <ul>
    <li>Home</li>
    <li>Page 1</li>
    <li>Page 2</li>
    <li>Page 3</li>
    <li>Page 4</li>
    <li>Page 5</li>
    <li>Page 6</li>
    <li>Page 7</li>
  </ul>
  <div id="contentContainer">
    <header>
      <div href="" onclick="openNav();" class="button"></div>
    </header>
    <div id="placeCheckHere"></div>
  </div>
</div>
function closeNav() {
 $('#contentContainer').removeClass('moveOut').addClass('moveIn');
  $('#navContainer ul').removeClass('slideIn').addClass('slideOut');
  $('#placeCheckHere').html("");
}

function openNav() { 
    $('#contentContainer').removeClass('moveIn').addClass('moveOut');
    $('#navContainer ul').removeClass('slideOut').addClass('slideIn');
    $('#placeCheckHere').html("<div id='checkNavDiv' onclick='closeNav();'></div>");  
}
从右向左

css

* {
  padding: 0;
  margin: 0;
}

html, body {
  width: 100%;
  height: 100%;
}

body {
  font-family: 'Helvetica';
  font-weight: 300;
}

#navContainer {
  width: 85%;
  height: 100%;
  padding-right: 15%;
  display: block;
  background: #222;
  position: relative;
  top: 0px;
  left: 0px;
  overflow-x: hidden;
  z-index: 1;
}

ul {
  list-style: none;
  padding: 10px;
}

li {
  padding: 10px;
  color: #eee;
}

#contentContainer {
  width: 100%;
  min-height: 100%;
  position: absolute;
  background: #ddd;
  z-index: 2;
  top: 0px;
  left: 0px;
  box-shadow: 0 0 40px black;
}

#checkNavDiv {
  width: 100%;
  height: 100%;
  display: block;
  position: absolute;
  top: 0px;
  left: 0px;
  cursor: pointer;
}

header {
  width: 100%;
  height: 50px;
  background: #bbb;
  box-shadow: 0 2px 2px rgba(0, 0, 0, 0.5);
}

.button {
  width: 33px;
  height: 24px;
  background: url("http://birdsongmedia.com/images/menu-icon1.png");
  cursor: pointer;
  position: relative;
  top: 13px;
  left: 19px;
}

article {
  padding: 10px;
}

.moveOut {
  -webkit-animation: moveContentOut 0.35s ease;
  -webkit-transform: translate(85%, 0);
}

.moveIn {
  -webkit-animation: moveContentIn 0.35s ease;
  -webkit-transform: translate(0, 0);
}

@-webkit-keyframes moveContentOut {
  0% {
    -webkit-transform: translate(0, 0);
  }

  100% {
    -webkit-transform: translate(85%, 0);
  }
}

@-webkit-keyframes moveContentIn {
  0% {
    -webkit-transform: translate(85%, 0);
  }

  100% {
    -webkit-transform: translate(0, 0);
  }
}

.slideIn {
  -webkit-animation: navSlideIn 0.35s ease;
  -webkit-transform: translate(0, 0);
}

.slideOut {
  -webkit-animation: navSlideOut 0.35s ease;
  -webkit-transform: translate(-40px, 0);
}

@-webkit-keyframes navSlideIn {
  0% {
    -webkit-transform: translate(-40px, 0);
  }

  100% {
    -webkit-transform: translate(0, 0);
  }
}

@-webkit-keyframes navSlideOut {
  0% {
    -webkit-transform: translate(0, 0);
  }

  100% {
    -webkit-transform: translate(-40px, 0);
  }
}
    * {
  padding: 0;
  margin: 0;
}

html, body {
  width: 100%;
  height: 100%;
}

body {
  font-family: 'Helvetica';
  font-weight: 300;
}

#navContainer {
  width: 85%;
  height: 100%;
  padding-right: 15%;
  display: block;
  background: #222;
  position: relative;
  top: 0px;
  left: 0px;
  overflow-x: hidden;
  z-index: 1;
}

ul {
  list-style: none;
  padding: 10px;
}

#navContainer ul {
  position: relative;
  left: 110%;
}

li {
  padding: 10px;
  color: #eee;
}

#contentContainer {
  width: 100%;
  min-height: 100%;
  position: absolute;
  background: #ddd;
  z-index: 2;
  top: 0px;
  left: 0px;
  box-shadow: 0 0 40px black;
}

#checkNavDiv {
  width: 100%;
  height: 100%;
  display: block;
  position: absolute;
  top: 0px;
  left: 0px;
  cursor: pointer;
}

header {
  width: 100%;
  height: 50px;
  background: #bbb;
  box-shadow: 0 2px 2px rgba(0, 0, 0, 0.5);
}

.button {
  width: 33px;
  height: 24px;
  background: url("http://birdsongmedia.com/images/menu-icon1.png");
  cursor: pointer;
  position: relative;
  top: 13px;
  left: -19px;
  float: right;
}

article {
  padding: 10px;
}

.moveOut {
  -webkit-animation: moveContentOut 0.35s ease;
  -webkit-transform: translate(-85%, 0);
}

.moveIn {
  -webkit-animation: moveContentIn 0.35s ease;
  -webkit-transform: translate(0, 0);
}

@-webkit-keyframes moveContentOut {
  0% {
    -webkit-transform: translate(0, 0);
  }

  100% {
    -webkit-transform: translate(-85%, 0);
  }
}

@-webkit-keyframes moveContentIn {
  0% {
    -webkit-transform: translate(-85%, 0);
  }

  100% {
    -webkit-transform: translate(0, 0);
  }
}

.slideIn {
  -webkit-animation: navSlideIn 0.35s ease;
  -webkit-transform: translate(0, 0);
}

.slideOut {
  -webkit-animation: navSlideOut 0.35s ease;
  -webkit-transform: translate(-40px, 0);
}

@-webkit-keyframes navSlideIn {
  0% {
    -webkit-transform: translate(-40px, 0);
  }

  100% {
    -webkit-transform: translate(0, 0);
  }
}

@-webkit-keyframes navSlideOut {
  0% {
    -webkit-transform: translate(0, 0);
  }

  100% {
    -webkit-transform: translate(-40px, 0);
  }
}
<div id="navContainer">
  <ul>
    <li>Home</li>
    <li>Page 1</li>
    <li>Page 2</li>
    <li>Page 3</li>
    <li>Page 4</li>
    <li>Page 5</li>
    <li>Page 6</li>
    <li>Page 7</li>
  </ul>
  <div id="contentContainer">
    <header>
      <div href="" onclick="openNav();" class="button"></div>
    </header>
    <div id="placeCheckHere"></div>
  </div>
</div>
function closeNav() {
 $('#contentContainer').removeClass('moveOut').addClass('moveIn');
  $('#navContainer ul').removeClass('slideIn').addClass('slideOut');
  $('#placeCheckHere').html("");
}

function openNav() { 
    $('#contentContainer').removeClass('moveIn').addClass('moveOut');
    $('#navContainer ul').removeClass('slideOut').addClass('slideIn');
    $('#placeCheckHere').html("<div id='checkNavDiv' onclick='closeNav();'></div>");  
}
通用html和js

* {
  padding: 0;
  margin: 0;
}

html, body {
  width: 100%;
  height: 100%;
}

body {
  font-family: 'Helvetica';
  font-weight: 300;
}

#navContainer {
  width: 85%;
  height: 100%;
  padding-right: 15%;
  display: block;
  background: #222;
  position: relative;
  top: 0px;
  left: 0px;
  overflow-x: hidden;
  z-index: 1;
}

ul {
  list-style: none;
  padding: 10px;
}

li {
  padding: 10px;
  color: #eee;
}

#contentContainer {
  width: 100%;
  min-height: 100%;
  position: absolute;
  background: #ddd;
  z-index: 2;
  top: 0px;
  left: 0px;
  box-shadow: 0 0 40px black;
}

#checkNavDiv {
  width: 100%;
  height: 100%;
  display: block;
  position: absolute;
  top: 0px;
  left: 0px;
  cursor: pointer;
}

header {
  width: 100%;
  height: 50px;
  background: #bbb;
  box-shadow: 0 2px 2px rgba(0, 0, 0, 0.5);
}

.button {
  width: 33px;
  height: 24px;
  background: url("http://birdsongmedia.com/images/menu-icon1.png");
  cursor: pointer;
  position: relative;
  top: 13px;
  left: 19px;
}

article {
  padding: 10px;
}

.moveOut {
  -webkit-animation: moveContentOut 0.35s ease;
  -webkit-transform: translate(85%, 0);
}

.moveIn {
  -webkit-animation: moveContentIn 0.35s ease;
  -webkit-transform: translate(0, 0);
}

@-webkit-keyframes moveContentOut {
  0% {
    -webkit-transform: translate(0, 0);
  }

  100% {
    -webkit-transform: translate(85%, 0);
  }
}

@-webkit-keyframes moveContentIn {
  0% {
    -webkit-transform: translate(85%, 0);
  }

  100% {
    -webkit-transform: translate(0, 0);
  }
}

.slideIn {
  -webkit-animation: navSlideIn 0.35s ease;
  -webkit-transform: translate(0, 0);
}

.slideOut {
  -webkit-animation: navSlideOut 0.35s ease;
  -webkit-transform: translate(-40px, 0);
}

@-webkit-keyframes navSlideIn {
  0% {
    -webkit-transform: translate(-40px, 0);
  }

  100% {
    -webkit-transform: translate(0, 0);
  }
}

@-webkit-keyframes navSlideOut {
  0% {
    -webkit-transform: translate(0, 0);
  }

  100% {
    -webkit-transform: translate(-40px, 0);
  }
}
    * {
  padding: 0;
  margin: 0;
}

html, body {
  width: 100%;
  height: 100%;
}

body {
  font-family: 'Helvetica';
  font-weight: 300;
}

#navContainer {
  width: 85%;
  height: 100%;
  padding-right: 15%;
  display: block;
  background: #222;
  position: relative;
  top: 0px;
  left: 0px;
  overflow-x: hidden;
  z-index: 1;
}

ul {
  list-style: none;
  padding: 10px;
}

#navContainer ul {
  position: relative;
  left: 110%;
}

li {
  padding: 10px;
  color: #eee;
}

#contentContainer {
  width: 100%;
  min-height: 100%;
  position: absolute;
  background: #ddd;
  z-index: 2;
  top: 0px;
  left: 0px;
  box-shadow: 0 0 40px black;
}

#checkNavDiv {
  width: 100%;
  height: 100%;
  display: block;
  position: absolute;
  top: 0px;
  left: 0px;
  cursor: pointer;
}

header {
  width: 100%;
  height: 50px;
  background: #bbb;
  box-shadow: 0 2px 2px rgba(0, 0, 0, 0.5);
}

.button {
  width: 33px;
  height: 24px;
  background: url("http://birdsongmedia.com/images/menu-icon1.png");
  cursor: pointer;
  position: relative;
  top: 13px;
  left: -19px;
  float: right;
}

article {
  padding: 10px;
}

.moveOut {
  -webkit-animation: moveContentOut 0.35s ease;
  -webkit-transform: translate(-85%, 0);
}

.moveIn {
  -webkit-animation: moveContentIn 0.35s ease;
  -webkit-transform: translate(0, 0);
}

@-webkit-keyframes moveContentOut {
  0% {
    -webkit-transform: translate(0, 0);
  }

  100% {
    -webkit-transform: translate(-85%, 0);
  }
}

@-webkit-keyframes moveContentIn {
  0% {
    -webkit-transform: translate(-85%, 0);
  }

  100% {
    -webkit-transform: translate(0, 0);
  }
}

.slideIn {
  -webkit-animation: navSlideIn 0.35s ease;
  -webkit-transform: translate(0, 0);
}

.slideOut {
  -webkit-animation: navSlideOut 0.35s ease;
  -webkit-transform: translate(-40px, 0);
}

@-webkit-keyframes navSlideIn {
  0% {
    -webkit-transform: translate(-40px, 0);
  }

  100% {
    -webkit-transform: translate(0, 0);
  }
}

@-webkit-keyframes navSlideOut {
  0% {
    -webkit-transform: translate(0, 0);
  }

  100% {
    -webkit-transform: translate(-40px, 0);
  }
}
<div id="navContainer">
  <ul>
    <li>Home</li>
    <li>Page 1</li>
    <li>Page 2</li>
    <li>Page 3</li>
    <li>Page 4</li>
    <li>Page 5</li>
    <li>Page 6</li>
    <li>Page 7</li>
  </ul>
  <div id="contentContainer">
    <header>
      <div href="" onclick="openNav();" class="button"></div>
    </header>
    <div id="placeCheckHere"></div>
  </div>
</div>
function closeNav() {
 $('#contentContainer').removeClass('moveOut').addClass('moveIn');
  $('#navContainer ul').removeClass('slideIn').addClass('slideOut');
  $('#placeCheckHere').html("");
}

function openNav() { 
    $('#contentContainer').removeClass('moveIn').addClass('moveOut');
    $('#navContainer ul').removeClass('slideOut').addClass('slideIn');
    $('#placeCheckHere').html("<div id='checkNavDiv' onclick='closeNav();'></div>");  
}

  • 第1页
  • 第2页
  • 第3页
  • 第4页
  • 第5页
  • 第6页
  • 第7页
js

* {
  padding: 0;
  margin: 0;
}

html, body {
  width: 100%;
  height: 100%;
}

body {
  font-family: 'Helvetica';
  font-weight: 300;
}

#navContainer {
  width: 85%;
  height: 100%;
  padding-right: 15%;
  display: block;
  background: #222;
  position: relative;
  top: 0px;
  left: 0px;
  overflow-x: hidden;
  z-index: 1;
}

ul {
  list-style: none;
  padding: 10px;
}

li {
  padding: 10px;
  color: #eee;
}

#contentContainer {
  width: 100%;
  min-height: 100%;
  position: absolute;
  background: #ddd;
  z-index: 2;
  top: 0px;
  left: 0px;
  box-shadow: 0 0 40px black;
}

#checkNavDiv {
  width: 100%;
  height: 100%;
  display: block;
  position: absolute;
  top: 0px;
  left: 0px;
  cursor: pointer;
}

header {
  width: 100%;
  height: 50px;
  background: #bbb;
  box-shadow: 0 2px 2px rgba(0, 0, 0, 0.5);
}

.button {
  width: 33px;
  height: 24px;
  background: url("http://birdsongmedia.com/images/menu-icon1.png");
  cursor: pointer;
  position: relative;
  top: 13px;
  left: 19px;
}

article {
  padding: 10px;
}

.moveOut {
  -webkit-animation: moveContentOut 0.35s ease;
  -webkit-transform: translate(85%, 0);
}

.moveIn {
  -webkit-animation: moveContentIn 0.35s ease;
  -webkit-transform: translate(0, 0);
}

@-webkit-keyframes moveContentOut {
  0% {
    -webkit-transform: translate(0, 0);
  }

  100% {
    -webkit-transform: translate(85%, 0);
  }
}

@-webkit-keyframes moveContentIn {
  0% {
    -webkit-transform: translate(85%, 0);
  }

  100% {
    -webkit-transform: translate(0, 0);
  }
}

.slideIn {
  -webkit-animation: navSlideIn 0.35s ease;
  -webkit-transform: translate(0, 0);
}

.slideOut {
  -webkit-animation: navSlideOut 0.35s ease;
  -webkit-transform: translate(-40px, 0);
}

@-webkit-keyframes navSlideIn {
  0% {
    -webkit-transform: translate(-40px, 0);
  }

  100% {
    -webkit-transform: translate(0, 0);
  }
}

@-webkit-keyframes navSlideOut {
  0% {
    -webkit-transform: translate(0, 0);
  }

  100% {
    -webkit-transform: translate(-40px, 0);
  }
}
    * {
  padding: 0;
  margin: 0;
}

html, body {
  width: 100%;
  height: 100%;
}

body {
  font-family: 'Helvetica';
  font-weight: 300;
}

#navContainer {
  width: 85%;
  height: 100%;
  padding-right: 15%;
  display: block;
  background: #222;
  position: relative;
  top: 0px;
  left: 0px;
  overflow-x: hidden;
  z-index: 1;
}

ul {
  list-style: none;
  padding: 10px;
}

#navContainer ul {
  position: relative;
  left: 110%;
}

li {
  padding: 10px;
  color: #eee;
}

#contentContainer {
  width: 100%;
  min-height: 100%;
  position: absolute;
  background: #ddd;
  z-index: 2;
  top: 0px;
  left: 0px;
  box-shadow: 0 0 40px black;
}

#checkNavDiv {
  width: 100%;
  height: 100%;
  display: block;
  position: absolute;
  top: 0px;
  left: 0px;
  cursor: pointer;
}

header {
  width: 100%;
  height: 50px;
  background: #bbb;
  box-shadow: 0 2px 2px rgba(0, 0, 0, 0.5);
}

.button {
  width: 33px;
  height: 24px;
  background: url("http://birdsongmedia.com/images/menu-icon1.png");
  cursor: pointer;
  position: relative;
  top: 13px;
  left: -19px;
  float: right;
}

article {
  padding: 10px;
}

.moveOut {
  -webkit-animation: moveContentOut 0.35s ease;
  -webkit-transform: translate(-85%, 0);
}

.moveIn {
  -webkit-animation: moveContentIn 0.35s ease;
  -webkit-transform: translate(0, 0);
}

@-webkit-keyframes moveContentOut {
  0% {
    -webkit-transform: translate(0, 0);
  }

  100% {
    -webkit-transform: translate(-85%, 0);
  }
}

@-webkit-keyframes moveContentIn {
  0% {
    -webkit-transform: translate(-85%, 0);
  }

  100% {
    -webkit-transform: translate(0, 0);
  }
}

.slideIn {
  -webkit-animation: navSlideIn 0.35s ease;
  -webkit-transform: translate(0, 0);
}

.slideOut {
  -webkit-animation: navSlideOut 0.35s ease;
  -webkit-transform: translate(-40px, 0);
}

@-webkit-keyframes navSlideIn {
  0% {
    -webkit-transform: translate(-40px, 0);
  }

  100% {
    -webkit-transform: translate(0, 0);
  }
}

@-webkit-keyframes navSlideOut {
  0% {
    -webkit-transform: translate(0, 0);
  }

  100% {
    -webkit-transform: translate(-40px, 0);
  }
}
<div id="navContainer">
  <ul>
    <li>Home</li>
    <li>Page 1</li>
    <li>Page 2</li>
    <li>Page 3</li>
    <li>Page 4</li>
    <li>Page 5</li>
    <li>Page 6</li>
    <li>Page 7</li>
  </ul>
  <div id="contentContainer">
    <header>
      <div href="" onclick="openNav();" class="button"></div>
    </header>
    <div id="placeCheckHere"></div>
  </div>
</div>
function closeNav() {
 $('#contentContainer').removeClass('moveOut').addClass('moveIn');
  $('#navContainer ul').removeClass('slideIn').addClass('slideOut');
  $('#placeCheckHere').html("");
}

function openNav() { 
    $('#contentContainer').removeClass('moveIn').addClass('moveOut');
    $('#navContainer ul').removeClass('slideOut').addClass('slideIn');
    $('#placeCheckHere').html("<div id='checkNavDiv' onclick='closeNav();'></div>");  
}
函数closeNav(){
$('#contentContainer').removeClass('moveOut').addClass('moveIn');
$('#navContainer ul').removeClass('slideIn').addClass('slideOut');
$('#placeCheckHere').html(“”);
}
函数openNav(){
$('#contentContainer').removeClass('moveIn').addClass('moveOut');
$('#navContainer ul').removeClass('slideOut').addClass('slideIn');
$('#placeCheckHere').html(“”);
}

codepen链接对我不起作用,将无法加载。试着用我不明白,菜单打开得很好。你到底想做什么?@josh不。菜单不起作用。php+风格。css@user2947950菜单对我来说很好:在Chrome上可以,但在Firefox上不行。它可以!我认为它的CSS问题。。。有没有我可以把它们合并成一个?