为什么CSS转换不显示?



我试图使导航面板滑动在主菜单中的导航按钮的点击。不用说,这行不通。我以前做过这个,所以我不确定发生了什么。帮助吗?

<!-- Header -->
<div class="header">
  <a href="#"><i id="nav-button" class="fa fa-navicon"></i></a>
  <header class="logo">
    <a href="index.html"><img src="../Assets/images/logo.png" alt=""></a>
  </header>
  <a href="#"><i class="account-control fa fa-user"></i></a>
</div>
<div class="wrapper">
  <div id="content">
  </div>
  <!-- Collapsible Menu -->
  <div id="sidebar">
    <div class="nav-items">
      <nav class="mainmenu">
        <ul>
          <li><a href="#">Billing</a></li>
          <li><a href="#">Support</a></li>
          <li><a href="#">Servers</a></li>
          <li><a href="#">Settings</a></li>
          <li><a href="#">Reports</a></li>
        </ul>
      </nav>
    </div>
    <!-- Copyright -->
    <footer>
      <form action="" class="search">
        <input type="search" name="search" placeholder="Search">
      </form>
      <p class="copyright">asdf</p>
    </footer>
  </div>
</div>
有关CSS

/* Core */
*, *:before, *:after {
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}
body {
  display: block;
  font-family: "Open Sans", sans-serif;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.42857;
  color: black;
  background-color: white;
}
.wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  top: 100px;
  z-index: 0;
  overflow: hidden;
}
#content {
  position: relative;
  left: 0;
  z-index: 5;
  height: 100%;
  overflow: auto;
  -webkit-transition: -webkit-transform 0.5s;
  -moz-transition: -moz-transform 0.5s;
  transition: transform 0.5s;
}
.sidebar-open #content {
  -webkit-transform: translate(200px, 0);
  -moz-transform: translate(200px, 0);
  transform: translate(200px, 0);
}
/* Header */
.header {
  background-color: #222222;
  width: 100%;
  height: 100px;
  position: absolute;
  top: 0;
  z-index: 1;
}
#nav-button {
  font-size: 24px;
  color: white;
  position: absolute;
  left: 40px;
  top: 50%;
  -webkit-transform: translateY(-50%);
  -moz-transform: translateY(-50%);
  transform: translateY(-50%);
}
#nav-button.open {
  -webkit-transform: rotate(90deg);
  -moz-transform: rotate(90deg);
  transform: rotate(90deg);
}
.logo {
  position: absolute;
  top: 50%;
  left: 50%;
  -webkit-transform: translate(-50%, -50%);
  -moz-transform: translate(-50%, -50%);
  transform: translate(-50%, -50%);
}
.account-control {
  font-size: 24px;
  color: white;
  position: absolute;
  right: 40px;
  top: 50%;
  -webkit-transform: translateY(-50%);
  -moz-transform: translateY(-50%);
  transform: translateY(-50%);
}
/* Navigation */
#sidebar {
  position: absolute;
  top: 100px;
  left: 0;
  visibility: hidden;
  width: 200px;
  height: 100%;
  background: #222222;
  opacity: 1;
  z-index: 1;
  -webkit-transform: all 0.5s;
  -moz-transform: all 0.5s;
  transform: all 0.5s;
  -webkit-transform: translate3d(0, -100%, 0);
  -moz-transform: translate3d(0, -100%, 0);
  transform: translate3d(0, -100%, 0);
}
.sidebar-open #sidebar {
  visibility: visible;
  -webkit-transition-timing-function: ease-in-out;
  -moz-transition-timing-function: ease-in-out;
  transition-timing-function: ease-in-out;
  -webkit-transition-property: transform;
  -moz-transition-property: transform;
  transition-property: transform;
  -webkit-transform: translate3d(0, 0, 0);
  -moz-transform: translate3d(0, 0, 0);
  transform: translate3d(0, 0, 0);
  -webkit-transition-speed: 0.2s;
  -moz-transition-speed: 0.2s;
  transition-speed: 0.2s;
}
#sidebar:after {
  position: absolute;
  top: 0;
  right: 0;
  width: 100%;
  height: 100%;
  content: '';
  opacity: 1;
  -webkit-transition: opacity 0.5s;
  -moz-transition: opacity 0.5s;
  transition: opacity 0.5s;
}
.sidebar-open #sidebar:after {
  width: 0;
  height: 0;
  opacity: 0;
  -webkit-transition: opacity 0.5s, width 0.1s 0.5s, height 0.1s 0.5s;
  -moz-transition: opacity 0.5s, width 0.1s 0.5s, height 0.1s 0.5s;
  transition: opacity 0.5s, width 0.1s 0.5s, height 0.1s 0.5s;
}
.nav-items {
  max-height: 100%;
  position: relative;
  overflow: auto;
  bottom: 60px;
}
.mainmenu ul {
  margin: 0;
}
.mainmenu ul li a {
  padding: 0 40px;
  width: 100%;
  line-height: 60px;
  display: inline-block;
  color: #202020;
  text-decoration: none;
}
.mainmenu ul li a :hover, .mainmenu ul li a .active {
  background: #e1e1e1;
}
JavaScript

jQuery(document).ready(function($) {
  /* Sidebar */
  $('#nav-button, #content').click(function() {
    $('#nav-button').toggleClass('open');
    $('body').toggleClass('sidebar-open');
    return false;
  });
});(jQuery);

是的,我正在使用fontaawesome。:)

解决您最初问题的最大问题是由于overflow: hidden;.wrapper

这里它被删除了:DEMO。但这又带来了全新的问题。我建议你回去重构你的代码

是否尝试清空缓存?Ctrl-Shift-Del让浏览器重新加载你的css。

注意:如果你的用户发生了这种情况,试着在你的标题中改变css的链接,像这样:<link rel="stylesheet" href="css/main.css?v=2">

相关内容

  • 没有找到相关文章

最新更新