CSS+p實現懸浮效果的實例
- 網頁設計
- 關注:2.25W次
導語:Css+p,是現在網頁設計必不可少的部分,它可以做出各種各樣的效果。以下的是本站小編為大家蒐集的CSS+p實現的懸浮效果的`實例,希望對你有所幫助。
代碼如下:
<p class="side-bar">
<a href="#" class="icon-qq">QQ在線諮詢</a>
<a href="#" class="icon-chat">微信<p class="chat-tips"><i></i>
<img style="width:138px;height:138px;" src="helloweba.jpg" _fcksavedurl=""helloweba.jpg"" alt="微信訂閲號"></p></a>
<a target="_blank" href="" class="icon-blog">微博</a>
<a href=<a href=""></a> class="icon-mail">mail</a>
</p>
CSS
我們使用CSS來完成浮動即鼠標滑向彈出效果。我們準備一張圖片right_bg.png,包含了幾個內容的圖標,然後通過background-position各個圖標對應的a內容。我們使用position: fixed以及設置bottom和right值將-bar固定在右下角,這樣無論頁面如何滾動,-bar將一直在右下角位置不變。這裏需要提下ie6下fixed效果需要單獨處理,但本文不做詳解,放棄ie6吧。
代碼如下:
-bar a,-tips i {background: url(right_bg.png) no-repeat;}
-bar {width: 66px;position: fixed;bottom: 20px;right: 25px;font-size: 0;line-height: 0;z-index: 100;}
-bar a {width: 66px;height: 66px;display: inline-block;background-color: #ddd;margin-bottom: 2px;}
-bar a:hover {background-color: #669fdd;}
-bar -qq {background-position: 0 -62px;}
-bar -chat {background-position: 0 -130px;position: relative;}
-bar -blog {background-position: 0 -198px;}
-bar -mail {background-position: 0 -266px;}
這裏還有個鼠標滑向微信圖標的效果,當鼠標hover時,-tips的display屬性設置為block,並且設置定位位置,一下代碼還包含了一個箭頭的CSS寫法:
代碼如下:
-bar -chat:hover -tips {display: block;}
-tips {padding: 20px;border: 1px solid #d1d2d6;position: absolute;right: 78px;top: -55px;background-color: #fff;display: none;}
-tips i {width: 9px;height: 16px;display: inline-block;position: absolute;right: -9px;top: 80px;background-position:-88px -350px;}
-tips img {width: 138px;height: 138px;}
- 文章版權屬於文章作者所有,轉載請註明 https://xuezhezhai.com/zh-mo/sjzz/sjzz/xpwk5.html