当前位置: 代码迷 >> JavaScript >> js怎么设置 DIV层中的图片 部分区域显示
  详细解决方案

js怎么设置 DIV层中的图片 部分区域显示

热度:96   发布时间:2012-03-16 16:34:56.0
js如何设置 DIV层中的图片 部分区域显示
js如何设置   DIV层中的图片   部分区域显示
其余部分   显示下层内容   ,但点击   非显示区域,获得的对象仍是   div层对象

------解决方案--------------------
SORRY,少看了个条件,晚上我试试其他的方法吧,用滤镜有可能可以实现
------解决方案--------------------
以前写的,不用filter css实现filter,还没有写完,用样式1可用:D,图片下载完成后有效。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN "
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<title> - http://www.never-online.net </title>
<meta http-equiv= "ImageToolbar " content= "no " />
<meta name= "author " content= "never-online, BlueDestiny "/>
<meta name= "keywords " content= "never modules, Mozilla CSS, C#, .net, Reference, BlueDestiny, never-online "/>
<meta name= "description " content= "javascript reference, c sharp artilces "/>
<meta name= "creator.name " content= "never-online, BlueDestiny " />
<style type= "text/css " media= "all " title= "Default ">
.myFilterWrap { position:relative; border:1px solid #555; }
.myFiltercss { position:absolute; clip:rect(0 0 0 0); }
</style>
<script type= "text/javascript ">
// <![CDATA[
// http://www.never-online.net
// by never-online
var mysrc = "http://zi.csdn.net/2007.04/windows%20internal4.16.gif ";

function myFilter (src, dir, isfilterin) {

if (!document.body) return false;
var cachep = new Image(); cachep.src = src;
var nDelay = 10; var strFt = " ";

var wrap = document.createElement( "DIV ");
var image = document.createElement( "IMG ");
wrap.className = "myFilter ";
document.body.appendChild(wrap);

image.height = cachep.height; image.width = cachep.width;
image.src = cachep.src; image.className = "myFiltercss ";
wrap.appendChild(image);

function fnFt (dir) {
if (1==dir) {
return "rect( "+(cnt++)+ " auto auto auto) ";
} else if (2==dir) {
return "rect(auto "+(cnt++)+ " auto auto) ";
} else if (3==dir) {
return "rect(auto auto "+(cnt++)+ " auto) ";
} else if (4==dir) {
return "rect(auto auto auto "+(cnt++)+ ") ";
} else {
return "rect( "+(cnt++)+ " "+(cnt++)+ " "+(cnt++)+ " "+(cnt++)+ ") ";
}
};


var cnt = 0; cachep.onload = function Fn () {
image.style.clip = fnFt(1);
if (cnt <=100) this._timeout=window.setTimeout(Fn, nDelay);
else window.clearTimeout(this._timeout);
};

}
//]]>
</script>
</head>

<body id= "www.never-online.net ">
<script type= "text/javascript ">
// <![CDATA[
myFilter.call(this, mysrc);
//]]>
</script>
</body>
</html>
  相关解决方案