導語: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;}