Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/432.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 侧边文本折叠菜单关闭_Javascript_Html_Css - Fatal编程技术网

Javascript 侧边文本折叠菜单关闭

Javascript 侧边文本折叠菜单关闭,javascript,html,css,Javascript,Html,Css,如何防止侧菜单关闭时文本折叠。查看代码笔,您将看到当菜单关闭时,菜单项/文本彼此重叠。我尝试过在菜单项上隐藏溢出,但不起作用。有什么想法吗 见代码笔: 一种解决方案是更改右侧属性,而不是宽度。因此,您可以将侧边栏的开始设置为right:-400px,并在单击按钮时将其更改为right:0px。然后在关闭菜单时反转 看到我的密码笔了吗 这样,文本将永远不会折叠。如果不切换宽度,而是更改了正确的位置,该怎么办。所以当它的右边关闭时:-400px,当它的右边打开时:0。这将在不折叠文本的情况下添加相同

如何防止侧菜单关闭时文本折叠。查看代码笔,您将看到当菜单关闭时,菜单项/文本彼此重叠。我尝试过在菜单项上隐藏溢出,但不起作用。有什么想法吗

见代码笔:


一种解决方案是更改右侧属性,而不是宽度。因此,您可以将侧边栏的开始设置为right:-400px,并在单击按钮时将其更改为right:0px。然后在关闭菜单时反转

看到我的密码笔了吗


这样,文本将永远不会折叠。

如果不切换宽度,而是更改了正确的位置,该怎么办。所以当它的右边关闭时:-400px,当它的右边打开时:0。这将在不折叠文本的情况下添加相同的效果。示例:@sunrism的想法完全相同。
<header>
  <div class="container-fluid">
    <div class="row">
      <nav class="navbar bg-faded fixed-top" id="slide-nav">
        <div class="nav-wrapper">
              <div class="nav-logo">

                <span class="navbar-text menu-toggle" onclick="openNav()"><i class="fa fa-bars" aria-hidden="true"></i></span>
             </div>


              <div id="mySidenav" class="sidenav">
                <a href="javascript:void(0)" class="closebtn" onclick="closeNav()">&times;</a>
                <br>
                <br>
                <a href="#">Home</a>
                <a href="#">This Is Link One</a>
                <a href="#">This Is Link Two</a>
                <a href="#">This Is Link Three</a>
                <a href="#">This IsLink Three</a>
                <a href="#">Link Three</a>
              </div>
       </div>

      </nav>
  </div>
</div>

    </nav>
</header>



    /* NAVIGATION */
.menu-toggle {
cursor:pointer;
float:right;
line-height: 60px;
}

.fa-bars {
  color: #fff;
  font-size: 30px;
}


.nav-wrapper {
  width: 83%;
  margin: 0 auto;
}


.navbar {
  height: 75px;
  background-color: gray;
}



/* The side navigation menu */
.sidenav {
    height: 100%; /* 100% Full-height */
    width: 0; /* 0 width - change this with JavaScript */
    position: fixed; /* Stay in place */
    z-index: 1; /* Stay on top */
    top: 0; /* Stay at the top */
    right: 0;
    background:rgba(75,156,211,0.9) url('../img/unc_pine_cb.svg') no-repeat;
    background-size: 200%;
    overflow-x: hidden; /* Disable horizontal scroll */
    padding-top: 60px; /* Place content 60px from the top */
    transition: 0.5s; /* 0.5 second transition effect to slide in the sidenav */
    overflow: hidden;
}

/* The navigation menu links */
.sidenav a {
    padding: 15px 8px 10px 32px;
    text-decoration: none;
    font-size: 25px;
    color: #fff;
    display: block;
    transition: 0.3s;
}


/* When you mouse over the navigation links, change their color */
.sidenav a:hover {
    color: #13284a;
    font-weight: 600;
}

/* Position and style the close button (top right corner) */
.sidenav .closebtn {
    position: absolute;
    top: 0;
    left: 0;
    font-size: 36px;
}




 /* Set the width of the side navigation to 250px */
function openNav() {
    document.getElementById("mySidenav").style.width = "400px";
}

/* Set the width of the side navigation to 0 */
function closeNav() {
    document.getElementById("mySidenav").style.width = "0";
}


// FADE OUT ON SCROLL DOWN
$(window).scroll(function(){
    $(".fade-to-top").css("opacity", 1 - $(window).scrollTop() / 350);
  });