css中的clip:rect()只能在绝对定位的元素上使用,包括fixed属性的元素,因为fixed也算绝对定位
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style>
</style>
<script>
function myfun()
{
//document.getElementById("img1").style.position="absolute";
}
</script>
<script src="test_2/Jquery_test/jquery.js"></script>
<script>
jQuery(document).ready(function(e) {
$("#btn").click(
function()
{
$("img").css(
{position:"fixed",
clip:"rect(0px 100px 200px 0px)"
});
}
)
});
</script>
</head>
<body>
<img id="img1" src="test_2/Jquery_test/11.jpg" width="200px" height="200px">
<p>this is a p i am libo</p>
<br/>
<input type="button" id="btn" value="切换绝对定位" onclick="myfun()">
</body>