案例:仿华为商品过渡效果

该博客详细介绍了如何通过HTML和CSS实现网页中商品展示的过渡效果,包括图片缩放、背景渐变和‘了解更多’按钮的上浮及箭头动画。利用Iconfont库添加字体图标,实现鼠标悬停时红色右箭头向右移动的动态效果,增强了用户体验。
摘要由CSDN通过智能技术生成

华为官网商品过渡效果:

鼠标移动到商品内,图片缩放、背景渐变色、了解更多上浮

且将鼠标放到了解更多上,红色右箭头会向右移动

案例模仿效果:

 用到的字体图标:iconfont-阿里巴巴矢量图标库

 

代码:

html:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="./iconfont/iconfont.css">
    <link rel="stylesheet" href="hw.css">
</head>
<body>
    <div class="pic">
        <img src="HUAWEI P50E.jpg" alt="HUAWEI P50E">
        <a href="#" class="mask"></a>
        <a href="#" class="more">
            <span>产品</span>
            <h2>HUAWEI P50E</h2>
            <p>万象新生</p>
            <div>
                <span>了解更多</span>
                <i class="iconfont icon-youjiantou"></i>
            </div>
        </a>
    </a>
</body>
</html>

css:

        * {
            margin: 0;
            padding: 0;
            font-size: 16px;
            color: #fff;
            box-sizing: border-box;
        }
        i {
            font-style: normal;
        }
        a {
            /* 去除a下划线 */
            text-decoration: none;
        }
        .pic {
            position: relative;
            margin: 100px auto;
            width: 446px;
            height: 445px;
            /* 超出的范围不可见 */
            overflow: hidden;
            /* 设置pic里的mask遮罩显示所需要的时间 */
            transition: opacity .7s;
            /* cursor: pointer; */
        }
        img {
            width: 446px;
            height: 445px;
            /* 设置img缩放需要的时间 */
            transition: transform .7s;
        }
        .pic:hover img{
            /* 缩放 */
            transform: scale(105%);
        } 
        .pic:hover .mask{
            /* 显示遮罩 */
            /* opacity: 1; */
            background-image: linear-gradient(
                transparent,
                rgba(0,0,0,.6)
            );
        }
        .mask {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            display: block;
            background-image: linear-gradient(
                transparent,
                rgba(0,0,0,.3)
            );
            /* 默认不可见,当鼠标移动到图片上显示 */
            /* opacity: 0; */
        }
        .pic:hover .more {
            bottom: 0;
            display: block;
        }
        .more {
            position: absolute;
            bottom: -50px;
            left: 0;
            padding: 25px 30px;
            width: 100%;
            transition: all .5s;
        }
        .more span:nth-child(1) {
            font-size: 18px;
        }
        .more h2 {
            margin: 8px 0;
            font-size: 24px;
        }
        .more p {
            margin-bottom: 30px;
            font-size: 18px;
            color: #cbcbcb;
        }
        .more div {
            font-size: 18px;
            color: #fff;
        }
        /* 字体图标 */
        .more div i {
            content: '\e629';
            color: #c7000b;
            font-weight: 700;
            font-family: 'iconfont';
            transition: all .2s;
        }
        .more div:hover i {
            content: '\e629';
            color: #a2131e;
            font-family: 'iconfont';
            font-weight: 700;
            margin-left: 4px;
        }
  • 2
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值