<html>
<head>
<style>
img {
position: absolute;
top: 50px;
}
</style>
</head>
<body>
<img id="myImg" src="/i/pic/w3logo.png" width="180" height="167">
<button type="button" onclick="clipImage()">剪裁图像</button>
<button type="button" onclick="clearClip()">不剪裁图像</button>
<script>
function clipImage() {
document.getElementById("myImg").style.clip = "rect(0px 90px 90px 0px)";
}
function clearClip() {
document.getElementById("myImg").style.clip = "auto";
}
</script>
</body>
</html>