html第四次作业

作业一:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>图片变色</title>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js">
    </script>
    <style>
        img {
            width: 200px;
            height: 200px;
            transition: filter 0.5s;
        }
    </style>
</head>
<body>
    <img id="color-change" src="kitty.jpg" alt="Original Image">
    <script>
 
        $(document).ready(function(){
 
            $("#color-change").click(function(){
 
                $(this).attr("src", "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fb-ssl.duitang.com%2Fuploads%2Fitem%2F201810%2F06%2F20181006174836_PGHmM.jpeg&refer=http%3A%2F%2Fb-ssl.duitang.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1723865534&t=f53d7807a484a98bd174a33ac9eb6908g");
 
            });
 
        });
    </script>
</body>
</html>

 

作业二:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>背景渐变</title>
    <style>
        body {
            height: 100vh;
            margin: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            transition: background 0.5s;
        }
    </style>
</head>
<body>
    <script>
        let direction = "to right";
 
        function changeGradientDirection() {
            if (direction === "to right") {
                document.body.style.background = "linear-gradient(to bottom, #00FFFF, #FF69B4)";
                direction = "to bottom";
            } else {
                document.body.style.background = "linear-gradient(to right, #00FFFF, #FF69B4)";
                direction = "to right";
            }
        }
 
        document.body.addEventListener("click", changeGradientDirection);
    </script>
</body>
</html>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值