通过定位和css3里的transform实现鼠标经过卡片动态滑动的效果

  • 实现效果
    在这里插入图片描述

  • html页面

<body>
    <div class="box">
        <div class="item">
            <div class="hover">
                hello
            </div>
        </div>
        <div class="item">
            <div class="hover">
                hello
            </div>
        </div>
        <div class="item">
            <div class="hover">
                hello
            </div>
        </div>
        <div class="item">
            <div class="hover">
                hello
            </div>
        </div>
        <div class="item">
            <div class="hover">
                hello
            </div>
        </div>
    </div>
</body>
  • css页面
 <style>
        .box {
            height: 200px;
        }
        .item {
            position: relative;
            float: left;
            width: 200px;
            height: 200px;
            margin: 20px 40px;
            border: 1px solid #ccc;
            overflow: hidden;
        }
        .hover {
            position: absolute;
            left: 0;
            bottom: 0;
            width: 200px;
            height: 45px;
            background: gold;
            opacity: .6;
            transform: translateY(45px);
            transition: ease-out .3s;
        }
        .item:hover .hover{
            transform: translateY(0);
        }
    </style>
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在 HTML5 和 CSS3 中,我们可以使用更多的特性来实现超链接在鼠标经过时显示不同的效果。下面是一些示例: 1. 使用 CSS3 transition 属性实现渐变效果 HTML 代码: ```html <a href="#">这是一个超链接</a> ``` CSS 代码: ```css a { color: red; text-decoration: none; transition: color 0.3s ease; } a:hover { color: blue; } ``` 在这个示例中,我们为超链接设置了红色的文本颜色和无下划线的文本装饰,使用了 CSS3 transition 属性来实现文本颜色的渐变效果。当用户将鼠标悬停在链接上时,文本颜色将从红色渐变为蓝色。 2. 使用 CSS3 transform 属性实现旋转效果 HTML 代码: ```html <a href="#">这是一个超链接</a> ``` CSS 代码: ```css a { color: red; text-decoration: none; transition: transform 0.3s ease; } a:hover { transform: rotate(45deg); } ``` 在这个示例中,我们为超链接设置了红色的文本颜色和无下划线的文本装饰,使用了 CSS3 transform 属性来实现文本旋转的效果。当用户将鼠标悬停在链接上时,文本将以 45 度的角度旋转。 3. 使用 CSS3 box-shadow 属性实现阴影效果 HTML 代码: ```html <a href="#">这是一个超链接</a> ``` CSS 代码: ```css a { color: red; text-decoration: none; transition: box-shadow 0.3s ease; } a:hover { box-shadow: 0 0 5px blue; } ``` 在这个示例中,我们为超链接设置了红色的文本颜色和无下划线的文本装饰,使用了 CSS3 box-shadow 属性来实现文本阴影的效果。当用户将鼠标悬停在链接上时,文本将出现蓝色的阴影效果
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值