javascript - 隐藏第一个面板上的导航 - PanelSnap 插件

标签 javascript jquery css

我正在为我的网站使用 guidobouman 的 PanelSnap 插件。但我想稍微调整一下以产生所需的效果。我想隐藏第一个面板上的导航并显示在其他面板上。

http://jsfiddle.net/NDkZz/

这是我现在使用的代码:

CSS

  html, body {
    margin: 0;
    padding: 0;
    height: 100%;
  }

  body {
    color: #ffffff;
    font-family: 'Lato';
    font-weight: 100;
    font-size: 32px;
  }

  h1 {
    font-weight: inherit;
    text-transform: uppercase;
    font-size: 250%;
    margin: 0;
  }

  a {
    color: inherit;
  }

  img {
    max-width: 100%;
  }

  p {
    max-width: 800px;
  }

  p.small,
  pre {
    font-size: 70%;
  }

  section {
    position: relative;
    overflow: hidden;
    width: 100%;
    height: 100%;
    background: #1abc9c;
  }

  section:nth-child(2n) {
    background: #16a085;
  }

  section section {
    background: #f1c40f;
  }

  section section:nth-child(2n) {
    background: #f39c12;
  }

  section pre {
    background: #16a085;
  }

  section:nth-child(2n) pre {
    background: #1abc9c;
  }

  .panels {
    position: absolute;
    overflow-y: scroll;
    overflow-x: hidden;
    width: 100%;
    height: 100%;
  }

  .menu {
    position: absolute;
    z-index: 100;
  }


  .menu a {
    display: block;
    width: 100%;
    padding: 25px;
    background: #0ff3ec;
    text-decoration: none;
    margin: 0 0 25px 0;
  }

  .menu a.active,
  .menu a:active,
  .menu a:hover {
    background: #1195f3;
  }



HTML

<section class="menu_demo">
  <div class="menu">
    <a href="" data-panel="first">
      First panel
    </a>
    <a href="" data-panel="second" class="active">
      Second panel
    </a>
    <a href="" data-panel="third">
      Third panel
    </a>
  </div>
  <div class="panels">
    <section data-panel="first">
      <h1>First</h1>
    </section>
    <section style="background-color: black;" data-panel="second">
      <h1>Second</h1>
    </section>
    <section data-panel="third">
      <h1>Third</h1>
    </section>
  </div>
</section>

<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="http://guidobouman.github.io/jquery-panelsnap/jquery.customEvents.js"></script>
<script src="http://guidobouman.github.io/jquery-panelsnap/jquery.panelSnap.js"></script>
<script>
  // Basic demo
  $('body').panelSnap();

  // Menu demo
  $('.menu_demo .panels').panelSnap({
    $menu: $('.menu_demo .menu')
  });
</script>

最佳答案

我不确定您是否打算在他们单击“第一面板”链接时隐藏“第一面板”/“第二面板”/“第三面板”链接(如果是这样,他们将如何再次看到菜单?)但如果是这样,这应该可以解决问题:

$('.menu a').click(function(){
    if($(this).attr('data-panel') == 'first'){
        $('.menu').hide();
    } else {
        $('.menu').show();
    }
});

http://jsfiddle.net/NDkZz/1/

关于javascript - 隐藏第一个面板上的导航 - PanelSnap 插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18347939/

相关文章:

javascript - 从函数导出变量

javascript - PhoneGap : Detect if running on desktop browser

javascript - href 和 js 一起工作在 html 上

javascript - jQuery 关于单选按钮的更改事件

javascript - 在代码隐藏中生成的链接/图标不会显示在某些移动设备上

javascript - 在 iframe 中环绕广告文字

JavaScript 数组搜索之间的日期时间

javascript - Javascript for 循环中的 Ajax 请求

javascript - TinyMCE 与 FancyBox

HTML/CSS 禁用自动完成建议输入密码