简体   繁体   English

单击菜单中的幻灯片内容

[英]slide content when click in the menu

i want only a simple website menu in the left side when clicking one of the link's content in the right side will slide left. 我只想在左侧单击链接中的一个内容时向左滑动一个简单的网站菜单。

working fiddle here 这里工作

html html

<div class="contentLeft">
        <ul>
            <li><a class="selectBox" href="#">sample</a></li>
            <li><a class="selectBox" href="#">sample1</a></li>
            <li><a class="selectBox" href="#">sample2</a></li>
        </ul>    

    </div>

<div class="contentRight">
    <div class="selectBoxContent">its</div>
    <div class="selectBoxContent">my</div>
    <div class="selectBoxContent">way</div>
</div>

jquery jQuery的

$(function() {

            $('.selectBox').click(function() {
         $('.selectBoxContent').slideLeft('fast');
        return false;

    });
        });

css 的CSS

.contentLeft {
    border:1px solid green;
    width:30%;
    float:left;
}

.contentRight {
    border:1px solid red;
    width:64%; 
    float:right;
    height:400px;
}
.selectBoxContent {
    width:100%;
    height:400px;
    display:none;
}

You could use .animate rather then slide. 您可以使用.animate而不是幻灯片。 So something like 所以像

JQuery jQuery查询

$(function() {
  $('.selectBox').click(function() {
    $('.selectBoxContent').fadeIn().animate({
      right: "0"
     }, 1000);
    return false;
  });
});

CSS 的CSS

.contentRight {
    border:1px solid red;
    width:64%; 
    float:right;
    height:400px;
    overflow: hidden;
    position: relative;
}

.selectBoxContent {
    width:100%;
    height:400px;
    display:none;
    right: -100%;
    position: relative;
}

By using jQuery UI - Slide Effect we can achieve this. 通过使用jQuery UI-Slide Effect,我们可以实现这一目标。

jQuery : jQuery的

 $('.selectBoxContent').toggle( "slide" );
    return false;
 });

SEE DEMO 查看演示

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

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