<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>图片变色</title>
<script src="03.JS\3.8JS案例加强\JQuery.js"></script>
<style>
.image-filter {
display: inline-block;
transition: filter 0.5s ease;
}
.image-filter img {
width: 800px;
height: 600px;
display: block;
}
</style>
</head>
<body>
<div class="image-filter">
<img src="D:\study\云计算\web\code\01.html\1作业习题\作业材料\超级马力欧兄弟.jpg" alt="Transformable Image">
</div>
<script>
$(document).ready(function(){
var filters = [
'brightness(5%) contrast(10%) sepia(0%)',
'brightness(1500%) contrast(1000%) sepia(0%)',
'brightness(50%) sepia(100%)',
'brightness(150%) sepia(20%)'
];
var currentIndex = 0;
$('.image-filter').click(function(){
currentIndex = (currentIndex + 1) % filters.length;
$(this).find('img').css('filter', filters[currentIndex]);
});
});
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>背景方向渐变</title>
<style>
body {
height: 100vh;
/* width: 500px; */
margin: 0;
background: linear-gradient(45deg,pink,purple);
/* transition: background 0.5s ease; */
}
</style>
</head>
<body>
<script>
var degrees = [45, 90, 135, 180, 225, 270, 315];
var currentIndex = 0;
document.body.onclick = function() {
currentIndex = (currentIndex + 1) % degrees.length;
var newGradient = `linear-gradient(${degrees[currentIndex]}deg, pink, purple)`;
document.body.style.background = newGradient;
};
</script>
</body>
</html>