CSS+p实现悬浮效果的实例
导语: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;}