美文网首页
JS百度分享栏

JS百度分享栏

作者: duJing | 来源:发表于2017-01-04 15:31 被阅读21次

一个百度分享栏, 当然其中用的动画知识,
也是之前动画的缓冲运动的内容,这里只是当作案例罢了!
其实原理很简单,无非鼠标移入移出时,触动的动画。
接下来是代码部分:
HTML页面

<div id="share">
    <h2>分享到</h2>
    <ul>
        <li><a href="###" class="a">一键分享</a></li>
        <li><a href="###" class="b">新浪微博</a></li>
        <li><a href="###" class="c">人人网</a></li>
        <li><a href="###" class="d">百度相册</a></li>
        <li><a href="###" class="e">腾讯朋友</a></li>
        <li><a href="###" class="f">豆瓣网</a></li>
        <li><a href="###" class="g">百度新首页</a></li>
        <li><a href="###" class="h">和讯微博</a></li>
        <li><a href="###" class="i">QQ 空间</a></li>
        <li><a href="###" class="j">百度搜藏</a></li>
        <li><a href="###" class="k">腾讯微博</a></li>
        <li><a href="###" class="l">开心网</a></li>
        <li><a href="###" class="m">百度贴吧</a></li>
        <li><a href="###" class="n">搜狐微博</a></li>
        <li><a href="###" class="o">QQ 好友</a></li>
        <li><a href="###" class="p">更多...</a></li>
    </ul>
    <div class="share_footer"><a href="###">百度分享</a><span></span></div>
</div>

CSS样式表

/*百度分享*/
#share {
    width : 210px;
    height: 315px;
    border:1px solid #ccc;
    position: absolute;
    top: 100px;
    left:-211px;
}
#share h2 {
    height: 30px;
    line-height: 30px;
    margin: 0;
    padding: 0;
    background: #eee;
    font-size: 14px;
    color:#666;
    text-indent: 10px;
}
#share ul{
    height: 254px;
    padding : 3px 0 2px 5px;
    background:#fff;
}
#share ul li {
    width: 96px;
    height: 28px;
    padding : 2px;
    float : left;
}
#share ul li a {
    display: block;
    width: 95px;
    height: 26px;
    line-height: 26px;
    text-decoration: none;
    text-indent: 30px;
    background-image: url(images/share_bg.png);
    background-repeat: no-repeat;
    color: #666;
}
#share ul li a.a {
    background-position: 5px 4px;
}
#share ul li a.b {
    background-position: 5px -26px;
}
#share ul li a.c {
    background-position: 5px -56px;
}
#share ul li a.d {
    background-position: 5px -86px;
}
#share ul li a.e {
    background-position: 5px -116px;
}
#share ul li a.f {
    background-position: 5px -146px;
}
#share ul li a.g {
    background-position: 5px -176px;
}
#share ul li a.h {
    background-position: 5px -206px;
}
#share ul li a.i {
    background-position: 5px -236px;
}
#share ul li a.j {
    background-position: 5px -266px;
}
#share ul li a.k {
    background-position: 5px -296px;
}
#share ul li a.l {
    background-position: 5px -326px;
}
#share ul li a.m {
    background-position: 5px -356px;
}
#share ul li a.n {
    background-position: 5px -386px;
}
#share ul li a.o {
    background-position: 5px -416px;
}
#share ul li a.p {
    background-position: 5px -446px;
}
#share ul li a:hover {
    opacity: 0.7;
    filter :alpha(opacity=70);
    background-color: #eee;
    color:#06f;
}
#share .share_footer {
    height: 26px;
    background: #eee;
    position: relative;
}
#share .share_footer a {
    position: absolute;
    top:7px;
    left:140px;
    padding:0px 0px 0 20px;
    background: #eee url(images/share_bg.png) no-repeat 0 -450px;
    text-decoration: none;
    color: #666;
}
#share .share_footer a:hover {
    color:#06f;
    opacity: 0.7;
    filter : alpha(opacity=70);
}
/*分享按钮*/
#share .share_footer span {
    display: block;
    width : 24px;
    height: 88px;
    background:url(images/share.png) no-repeat;
    position: absolute;
    top: -230px;
    left: 210px;
    cursor: pointer;
}

JS实现动画效果

// 百度分享栏
$("#share").css("top", (getInner().height - parseInt(getStyle($("#share").first(), "height"))) / 2 + 'px');
$("#share").hover(function () {
    $(this).animate({
        attr : "x",
        target : -1
    });
}, function () {
    $(this).animate({
        attr : "x",
        target : -211
    });
});

相关文章

  • JS百度分享栏

    一个百度分享栏, 当然其中用的动画知识, 也是之前动画的缓冲运动的内容,这里只是当作案例罢了! 其实原理很简单...

  • 2020-06-06

    点击导航栏,导航栏和下面的副栏变色变内容 css部分 html部分 js部分

  • 11 CSS布局

    单栏布局,http://js.jirengu.com/serizubahe/1/edit 三栏布局,http://...

  • tab栏封装

    通过原生js , 封装tab栏切换效果 结构样式略; js代码如下:

  • 百度系浏览器停止了部分服务 只保留最基本功能

    近日,百度浏览器再发公告,称将对包括桌面百度、百度工具栏、百度地址栏、百度极速浏览器,hao123浏览器在内的产品...

  • vue登录验证 demo

    axios.js (捕获token自然过期) router.js (捕获地址栏跳转) store/index.js...

  • 布局demo

    1、单栏布局 (http://js.jirengu.com/kukeqowive)2、三栏布局 (ht...

  • 作业11

    一栏布局http://js.jirengu.com/halefexequ/1/edithttp://js.jire...

  • 侧边隐藏分享栏的简单Demo

    侧边隐藏分享栏 一、Html布局 二、Css样式 三、Js部分 speed一定的匀速运动 speed改变的缓冲运动

  • 20160829 接口

    接口 百度分享 微博开放平台 微信开放平台 mob 聚合数据 天气接口 js请求代码

网友评论

      本文标题:JS百度分享栏

      本文链接:https://www.haomeiwen.com/subject/oogovttx.html