侧边固定栏的制作

#在网页中经常可以看见固定侧边栏,下面就介绍一下他们的实现过程:
首先用html写需要定位的文字及结构,一般用无序列表写:

<body>
    <ul class="fixul">
        <li class="fixli">
            <a href="#"></a>
            <p class="p">
                <span>400-888-1234</span>
                <span>7x24小时为您服务</span>
            </p>
        </li>
        <li class="fixli">
            <a href="#"></a>
            <p class="p">
                <span>联系客服</span>
                <span>CUSTOMER SERVICE</span>
            </p>
        </li>
        <li class="fixli">
            <a href="javascript:void()"></a>
            <div>
                <i></i>
                <span>扫码关注百度一下</span>
            </div>
        </li>
        <li class="fixli">
            <a href="#"></a>
        </li>
    </ul>
</body>

在这里插入图片描述

再次用css设置样式,首先把ul固定定位到屏幕右下方;然后再一步步设置效果,代码如下:

        .fixul li {
            list-style: none;
        }
        /* 将ul固定定位到屏幕右下方 */
        
        .fixul {
            position: fixed;
            height: 240px;
            width: 190px;
            bottom: 10px;
            right: 10px;
            text-align: right;
        }
        
        .fixul .fixli {
            height: 60px;
            position: relative;
        }
        
        .fixul .fixli a {
            display: inline-block;
            height: 50px;
            width: 50px;
        }
        
        .fixul .fixli:nth-of-type(3) div {
            height: 140px;
            width: 123px;
            position: relative;
            position: absolute;
            top: 0;
            left: 0;
            display: none
        }
        /* 给a标签添加背景图片 */
        
        .fixul .fixli:nth-of-type(1) a {
            background: url('../img/Tel.png') no-repeat;
        }
        
        .fixul .fixli:nth-of-type(2) a {
            background: url('../img/QQ.png') no-repeat;
        }
        
        .fixul .fixli:nth-of-type(3) a {
            background: url('../img/WeChat.png') no-repeat;
        }
        
        .fixul .fixli:nth-of-type(3) i {
            position: absolute;
            left: 0px;
            height: 140px;
            width: 123px;
            border: 1px solid #15aafb;
            border-radius: 3px;
            background: url('../img/erweima.png') no-repeat;
            background-position: center 4px;
        }
        
        .fixul .fixli:nth-of-type(3) span {
            position: absolute;
            bottom: 9px;
            left: 9px;
            color: #15aafb;
        }
        
        .fixul .fixli:nth-of-type(4) a {
            background: url('../img/Top.png') no-repeat;
        }
        
        .fixul .fixli:nth-of-type(1) p span:nth-of-type(1) {
            font-size: 14px;
            display: block;
        }
        /* 隐藏文字 */
        
        .fixul .fixli .p {
            position: absolute;
            top: -13px;
            left: 5px;
            display: none;
            text-align: center;
        }
        /* 文字换行 */
        
        .fixul .fixli .p span:nth-of-type(1) {
            font-size: 14px;
            display: block;
            color: #fff;
        }
        
        .fixul .fixli .p span:nth-of-type(2) {
            color: #c0e9ff;
        }
        /* 设置hover效果 */
        
        .fixul .fixli:nth-of-type(1) a:hover {
            width: 190px;
            background: url('../img/Tel1.png') no-repeat;
        }
        
        .fixul .fixli:nth-of-type(1) a:hover+p {
            display: inline-block;
        }
        
        .fixul .fixli:nth-of-type(2) a:hover {
            width: 190px;
            background: url('../img/QQ1.png') no-repeat;
        }
        
        .fixul .fixli:nth-of-type(2) a:hover+p {
            display: inline-block;
        }
        
        .fixul .fixli:nth-of-type(3) a:hover {
            background: url('../img/WeChat1.png') no-repeat;
        }
        
        .fixul .fixli:nth-of-type(3) a:hover+div {
            display: inline-block;
        }
        
        .fixul .fixli:nth-of-type(4) a:hover {
            background: url('../img/Top1.png') no-repeat;
        }

这是文字没有隐藏的效果
在这里插入图片描述
这是文字隐藏后的效果,也就是最终呈现效果
在这里插入图片描述

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值