IE下的CSS渐变滤镜,实现图片的渐入渐出

注意:CSS的渐变滤镜是IE的特有扩展,在Opera 8和Firefox 1中仍能正常使用,但是少了渐变效果。

cs代码:

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DirectoryInfo dic
= new DirectoryInfo(Server.MapPath("~/Repeater/images/"));
repPhtotos.DataSource
= dic.GetFiles("*.jpg");
repPhtotos.DataBind();
}
}

html代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.photo
{
width
:400px;
background-color
:White;
filter
:progid:DXImageTransform.Microsoft.Fade(duration=2);
}
</style>
<script type="text/javascript">
var photos = new Array();
window.setInterval(ShowImage,
5000);

function ShowImage() {
if (photos.length > 0) {
var index = Math.floor(Math.random() * photos.length);
var img = document.getElementById("imgph");
img.src
= photos[index];
if (img.filters) {
img.filters[
0].Apply();
img.filters[
0].Play();
}
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<img id="imgph" alt="" class="photo" />
<script type="text/javascript">
<asp:Repeater ID="repPhtotos" runat="server">
<ItemTemplate>
<%#Eval("Name","photos.push('images/{0}')") %>
</ItemTemplate>
</asp:Repeater>
ShowImage();
</script>
</div>
</form>
</body>
</html>


posted on 2011-03-14 17:01  Scarface  阅读(1732)  评论(0编辑  收藏  举报

导航