CSS3-阴影 效果做成的立体图片效果

这篇博客展示了如何利用CSS3的阴影效果为图片添加立体感。通过为图片设置不同方向和颜色的阴影,实现了鼠标悬停时图片阴影变化的交互效果,增强了用户体验。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

CSS3-阴影 <wbr>效果做成的立体图片效果
   
   
   
    <!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>图片阴影效果</title>
    <script src="js/jquery.js"></script>
    <style>
        #mypanel{
            width: 537px;
            height: 430px;
            margin: 90px auto;
        }
        img{
            -webkit-box-shadow:8px 8px 10px black;
            -moz-box-shadow:8px 8px 10px black;
        }
    </style>

</head>
<body>
    <div id="mypanel">

    </div>
    <script type="text/javascript">
        //图片的张数
        var img_count=4;
        for(var i=0;i<img_count;i++){
            var image=document_createElement_x("img");
            image.setAttribute("src","images/shadow"+(i+1)+".jpg");
            image.setAttribute("class","img");
            image.style.width="250px";
            image.style.margin="8px";
           
            document.getElementByIdx_x("mypanel").a(image);

            //设置鼠标移动到图片上变阴影的效果
            $(".img").each(function(){
                $(this).mouseover(function(){
                    $(this).css("-webkit-box-shadow","8px 8px 10px gray");
                    //鼠标变成小手形状
                    $(this).css("cursor","pointer");
                });
                $(this).mouseout(function(){
                    $(this).css("-webkit-box-shadow","8px 8px 10px black");
                });



            });
        }
    </script>
</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值