```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<style>
#Viewimg{
width:450px;
height:450px;
transition: all .05s;
}
</style>
<body>
<img id="Viewimg" src="../img/background.jpeg" />
<button onclick="setViewimg(true)" >放大</button>
<button onclick="setViewimg(false)">缩小</button>
<script>
let zoom=1;//默认缩放值
function setViewimg(state){
let Viewimg=document.getElementById('Viewimg');
if(state){
zoom+=0.1;
}else{
zoom-=0.1;
}
Viewimg.style=`transform: scale(${zoom});`
}
</script>
</body>
</html>
```
我帮你写。
不用部署,直接免费下载,打开就行,现成,哪有那么多套路:
https://sc.chinaz.com/jiaoben/210509337870.htm