JS百度分享欄

一個(gè)百度分享欄, 當(dāng)然其中用的動(dòng)畫知識(shí),
也是之前動(dòng)畫的緩沖運(yùn)動(dòng)的內(nèi)容,這里只是當(dāng)作案例罷了!
其實(shí)原理很簡單,無非鼠標(biāo)移入移出時(shí),觸動(dòng)的動(dòng)畫。
接下來是代碼部分:
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">人人網(wǎng)</a></li>
        <li><a href="###" class="d">百度相冊(cè)</a></li>
        <li><a href="###" class="e">騰訊朋友</a></li>
        <li><a href="###" class="f">豆瓣網(wǎng)</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">開心網(wǎng)</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實(shí)現(xiàn)動(dòng)畫效果

// 百度分享欄
$("#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
    });
});
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • Android 自定義View的各種姿勢1 Activity的顯示之ViewRootImpl詳解 Activity...
    passiontim閱讀 179,234評(píng)論 25 708
  • 選擇qi:是表達(dá)式 標(biāo)簽選擇器 類選擇器 屬性選擇器 繼承屬性: color,font,text-align,li...
    wzhiq896閱讀 2,127評(píng)論 0 2
  • 2017-04-19 華杉 儒家很大程度上是明哲保身,妥協(xié)的藝術(shù),王陽明則是奮不顧身,絕無妥協(xié)。 【答聶文蔚 春間...
    郁萍閱讀 1,065評(píng)論 0 0
  • 在自己迷茫的時(shí)候 覺得自己這也行那也不行 這也不會(huì)那也不會(huì)的時(shí)候 總是情不自禁的回去網(wǎng)上去找方法 比如: 如何快速...
    DukeDaimao閱讀 206評(píng)論 0 0
  • 最近剛剛讀完《從零開始做運(yùn)營》對(duì)于書中總結(jié)的框架知識(shí)點(diǎn),非常受用。作為一個(gè)工作多年的運(yùn)營人就應(yīng)該對(duì)于運(yùn)營的架構(gòu)有一...
    慕七七_(dá)閱讀 2,477評(píng)論 0 0

友情鏈接更多精彩內(nèi)容