前端小制作 Part.3---卡片展示

HTML

<body>
    <div class="background">
        <li class="luna">
            <img src="images/露娜.png">
            <p>露娜</p>
        </li>
    
        <li class="make">
            <img src="images/马可波罗.png">
            <p>马可波罗</p>
        </li>
    
        <li class="libai">
            <img src="images/李白.png">
            <p>李白</p>
        </li>
    
        <li class="jialuo">
            <img src="images/伽罗.png">
            <p>伽罗</p>
        </li>
    </div>
    <script type="text/javascript" src="Test.js"></script>
</body>

CSS

*{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
.background{
    display: flex;
    justify-content: space-evenly;
    align-items: center;

    margin: 100px 100px;
    width: 1200px;
    height: 600px;
    background-image: url(images/TechnologyBackGround.png);
}
li{
    position: relative;

    list-style: none;
    height: 350px;
    width: 240px;
    box-shadow: 5px 5px 5px grey;
    border-radius: 20px;

    transition: .2s linear;
}
p{
    position: absolute;
    visibility: hidden;
    bottom: 0%;
    left: 0%;

    height: 0px;
    width: 240px;
    border-bottom-left-radius: 20px;
    border-bottom-right-radius: 20px;
    backdrop-filter: blur(10px);    /*滤镜*/

    text-align: center;
    overflow: hidden;

    transition-property: height;
    transition: .2s linear;
}
li:hover{
    transform: scale(1.05);
    box-shadow: 7px 7px 10px grey;
}
li:hover p{
    height: 80px;

    line-height: 80px;
    color:#fff;
    
    visibility: visible;
}
img{
    width: 100%;
    height: 100%;
    border-radius: 20px;
    filter: saturate(1.1);
}

JavaScript

     // 获取卡片对象    
    var cardObjects = document.getElementsByTagName('li');

    //  鼠标移入cardObjects[i]卡片, 排他算法
    for(var i = 0; i < cardObjects.length; i ++){
        cardObjects[i].onmouseover = function(){
            for(var j = 0; j < cardObjects.length; j ++)
                cardObjects[j].style.opacity = "0.6";
            this.style.opacity = "1";
        }
    }
    
    // 鼠标从cardObjects[i]卡片移开
    for(var i = 0; i < cardObjects.length; i ++){      
        cardObjects[i].onmouseout = function(){
            for(var j = 0; j < cardObjects.length; j ++)
                cardObjects[j].style.opacity="1";
        }
    }

效果展示

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Jeffrey.pace

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值