简单教程
提交运行
代码编辑器:
<style> img{ position:absolute; top:100px; } </style> <script> function clipImage(){ document.getElementById("img1").style.clip="rect(0px 75px 75px 0px)"; } function clearClip(){ document.getElementById("img1").style.clip="auto"; } </script> <img id="img1" src="/static/i/img2.jpg" width="100" height="132"> <input type="button" onclick=clipImage() value="裁剪图片"> <input type="button" onclick=clearClip() value="不裁剪图片">
运行结果: