JavaScript 参考手册
Style clip 属性
剪辑图像为指定的形状
源代码:
点击运行 »
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>蜜蜂教程(mifengjc.com)</title> <style type="text/css"> 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> </head> <body> <img id="img1" src="/examples/paris.jpg" width="100" height="132"> <input type="button" onclick=clipImage() value="裁剪图片"> <input type="button" onclick=clearClip() value="不裁剪图片"> </body> </html>
运行结果:
点击运行 »