javascript – 单击时使用JQuery水平滑出内容,再次单击关闭?

我似乎无法找到我需要的东西.我没有太费力地解释它,我基本上需要这个网站右上角的“连接”社交媒体栏 – http://www.cmssquirrel.com/web_works/

我不会为此目的使用它,但它的工作方式与我需要的功能完全相同.我找到的所有东西似乎都是垂直菜单风格的东西.我需要在点击时水平扩展内容,再次点击再次隐藏它.不太清楚从哪里开始?

解决方法:

这里有一个起点而非抛光解决方案,但它应该让你朝着正确的方向前进.

DEMO

HTML

<div class="wrap">
    <a class="open" href="#">open</a>
    <div class="outer">
        <div class="slide">
            <a href="#">One</a>
            <a href="#">a</a>
            <a href="#">uaoeua</a>
            <a href="#">aoeue</a>
            <a href="#">aaoeeo</a>
        </div>
    </div>
</div>

jQuery的

var w = 0;

$('.slide').children().each(function() {
    w += $(this).outerWidth();
});

$('.outer').width(w+5);
$('.wrap').width(w);
$('.slide').css('left', w);

$('.open').toggle(function() {
    $('.slide').stop().animate({
        left: 0
    });
    $(this).html('close');
}, function() {
    $('.slide').stop().animate({
        left: w
    });
    $(this).html('open');
});

CSS

.wrap {
    position: relative;
    left: 50px;
    top: 20px;
}
.outer {
    height: 40px;
    position: relative;
    overflow: hidden;
}
.slide {
    border-radius: 19px 19px 19px 19px;
    position: absolute;
    top: 0;
    right: 0;
    background-color: black;
    height: 40px;
}
a {
    color: gray;
    line-height: 35px;
    float: left;
    outline: none;
}
.slide a {
    float: left;
    display: block;
    padding: 0 10px;
}
.slide > :first-child {
    padding-left: 15px;
}
.slide > :last-child {
    padding-right: 45px;
}
.open {
    position: absolute;
    right: -25px;
    top: 0;
    background-color: black;
    border-radius: 19px 19px 19px 19px;
    height: 40px;
    padding: 0 15px;
    z-index: 5;
}

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: &lt;span id=&quot...
jQuery 添加水印 &lt;script src=&quot;../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...