zoukankan      html  css  js  c++  java
  • 商品详情页顶部随滚动条由透明变不透明

    <div class="i-gd-header" id="header" style="background: rgba(255,255,255,0)">
        <div class="i-gd-header-left" onclick="closeWindiw(isApp)"><i class="iconfont icon-fanhui"></i></div>
        <div class="i-gd-header-center">商品详情</div>
        <div class="i-gd-header-right">
            <div class="iconfont icon-xin"></div>
            <div class="iconfont icon-fenxiang3"></div>
        </div>
    </div>
    .i-gd-header {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 91;
        width: 100%;
        background-color: #fff;
        display: flex;
        align-items: center;
        font-size: 14px;
        height: 45px;
    }
    
    .i-gd-header-left {
        width: calc(30% - 20px);
        padding: 0 10px;
    }
    
    .i-gd-header-left i {
        font-weight: bold;
        color: #333;
    }
    
    .i-gd-header-center {
        text-align: center;
        width: 40%;
        font-size: 16px;
        color: rgba(0,0,0,0);
    }
    
    .i-gd-header-right {
        width: calc(30% - 20px);
        padding: 0 10px;
        display: flex;
        align-items: center;
        flex-direction: row-reverse;
    }
    
    .i-gd-header-right .iconfont{
        color: #fff;
        font-size: 16px;
        z-index: 99;
        background: #666;
        margin-left: 8px;
        width: 30px;
        height: 30px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
    }
                $(document).scroll(function() {
                    var scroH = $(document).scrollTop();  //滚动高度
                    var nums = scroH/500;//距离顶部高度超过500px时完全不透明
                    $(".i-gd-header-center").css("color",'rgba(0,0,0,'+nums+')');
                    $(".i-gd-header").css("background",'rgba(255,255,255,'+nums+')');
                    $(".i-gd-header-right .iconfont").css("background",'rgba(102, 102, 102,'+(1 - nums)+')');
    $(".i-gd-header-right .iconfont").css("color",'rgb('+(255 - ((255 - 102)/2)*nums)+', '+(255 - ((255 - 102)/2)*nums)+', '+(255 - ((255 - 102)/2)*nums)+')');
                });
  • 相关阅读:
    跳出iframe
    leetcode 225. Implement Stack using Queues
    leetcode 206. Reverse Linked List
    leetcode 205. Isomorphic Strings
    leetcode 203. Remove Linked List Elements
    leetcode 198. House Robber
    leetcode 190. Reverse Bits
    leetcode leetcode 783. Minimum Distance Between BST Nodes
    leetcode 202. Happy Number
    leetcode 389. Find the Difference
  • 原文地址:https://www.cnblogs.com/shark1100913/p/12002466.html
Copyright © 2011-2022 走看看