简体   繁体   English

jQuery-水平+垂直导航栏

[英]jQuery - Horizontal + vertical navbar

I'm trying to achieve the result of the following blueprints: 我正在尝试实现以下蓝图的结果:

蓝图

Sadly, I'm very new to JavaScript and jQuery, so I'd need some help. 不幸的是,我对JavaScript和jQuery还是很陌生,所以我需要一些帮助。

The idea is that the vertical nav/slider, 这个想法是垂直导航/滑动
follows your cursor, 跟随您的光标,
when hovering over the horizontal navbars links, 将鼠标悬停在水平导航栏链接上时,
revealing sub-links, like a dropdown menu. 显示子链接,例如下拉菜单。

I'm not asking you to do the whole job for me, but maybe give me a few tips and tell me how to get started? 我不是要你为我做全部工作,而是要给我一些提示,告诉我如何开始?

Experimental Fiddle of HTML and CSS HTML和CSS的实验小提琴

CODE: 码:

HTML HTML

  <section class="container">
  <div class="fs-nav-vr">
  <ul>
  <li>Linkki</li>
  <li>Hinkki</li>
  <li>Sinkki</li>
  </div>
  <div class="pusher"></div>
   <section class="sc-nav">
<div class="fs-nav">
<nav>
    <div onclick=" window.location = 'http://google.com'">
        <a >Linkki</a>
    </div><div>
        <a href="#">Hinkki</a>
    </div><div>
        <a href="#">Sinkki</a>
    </div>
</nav>
</div>

  </section>

</div>

CSS CSS

.fs-nav-vr {
    display: block;
    top: 0;
    height: 100%;
    width: 10%;
    padding: 0;
    margin: 0;
    opacity: 0.6;
    z-index: 2;
    left: 15%;
    background: red;
    position: absolute;
}
.fs-nav {
    height: 15%;
    display: block;
    width: 100%;
    top: 65%;
    padding: 0;
    margin: 0;
    color: relative;
    text-align:center;
    background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0.17, rgb(61, 61, 61)), color-stop(0.66, rgb(87, 84, 87)));
    background-image: -o-linear-gradient(bottom, rgb(61, 61, 61) 17%, rgb(87, 84, 87) 66%);
    background-image: -moz-linear-gradient(bottom, rgb(61, 61, 61) 17%, rgb(87, 84, 87) 66%);
    background-image: -webkit-linear-gradient(bottom, rgb(61, 61, 61) 17%, rgb(87, 84, 87) 66%);
    background-image: -ms-linear-gradient(bottom, rgb(61, 61, 61) 17%, rgb(87, 84, 87) 66%);
    background-image: linear-gradient(to bottom, rgb(61, 61, 61, 0.7) 17%, rgb(87, 84, 87) 66%);
    opacity: 0.8;
    overflow: hidden;
}
.fs-nav nav div {
    display: inline-block;
    text-align:center;
    cursor: pointer;
    border: solid 1px gray;
    padding: 2%;
    margin: 0;
    font-size: 40px;
    background-color: #999999;
    -webkit-transition: background-color 0.2s ease-in-out;
    -moz-transition: background-color 0.2s ease-in-out;
    -ms-transition: background-color 0.2s ease-in-out;
    -o-transition: background-color 0.2s ease-in-out;
    transition: background-color 0.2s ease-in-out;
}

This should be good for start and understanding what you need to do 这对于开始并了解您需要做什么很有帮助

HTML HTML

<div class="h-nav"> 

<div class="vert-nav-container">
<a class="link1" href=""> option 1 </a>
<a class="link2" href=""> option 2 </a>
<a class="link3" href=""> option 3 </a>

    <div class="v-nav">
        <ul style="margin-top:40px">
            <li>a</li>
            <li>b</li>
            <li>c</li>
        <ul>    
    </div>

</div>

jQuery jQuery的

$(".link1").mouseenter(function(){
     $(".v-nav").css({'left':'0px'})
});

$(".link2").mouseenter(function(){
     $(".v-nav").css({'left':'90px'})
});

$(".link3").mouseenter(function(){
    $(".v-nav").css({'left':'180px'})
});

For every link you have mouse event, you can add new things there like for example showing different sets of links for every option. 对于每个具有鼠标事件的链接,您都可以在其中添加新内容,例如为每个选项显示不同的链接集。

http://jsfiddle.net/4qdyK/36/ http://jsfiddle.net/4qdyK/36/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM