asp.net+js方式实现的幻灯图片效果展示

2024-03-17 12:48

本文主要是介绍asp.net+js方式实现的幻灯图片效果展示,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

最近一直在出差中,由于以前政府网站项目中的一个图片幻灯不知道咋的不能用了,图片出不来,原先的方式是直接通过Adobe的插件实现的,检查了一下,没发现问题,后来干脆换了个js的,效果如下:


main.css文件内容如下:

/*********CSS reset ***********/
*{margin:0;padding:0;}
ul,li,ol{ list-style:none;}
img,a img{ border:none;}
table{ border-collapse:collapse; border-spacing:0;}
em,i,u{ font-style:normal;}
a{ text-decoration:none;color:#434343;}
a:hover{ text-decoration:underline; color:#ff4000;}
body{font-size:12px; font-family:"宋体";color:#434343;}
.clear{clear:both;  font-size:0; overflow:hidden; height:0;}
.blank10{clear:both;  font-size:0; overflow:hidden; height:10px;}
.blank{clear:both;  font-size:0; overflow:hidden; height:10px; background:#FFF;}
/*********content css定义***********/
#content{width:960px;margin:0 auto;}
h1,h2,h3{ font-family:"微软雅黑";color:#00659b;}
h1,h2,h3,h4,h5,h6{ font-weight:bold;}
#footer{padding-bottom:0;margin:0px auto 0;}
/*********main css定义***********/
.mb15 {margin-bottom: 0px;}
#main{width:960px; margin:6px auto 10px; overflow:hidden;}/*********图片切换 css定义***********/
.sub_box{width:235px; height:190px; float:left; position:relative; overflow:hidden; border:1px solid #cccccc; background:url(http://trip.elong.com/trip/default/news/images/logo_gray.jpg) center center no-repeat; *background:url(http://trip.elong.com/trip/default/news/images/logo_gray.jpg) 220px 120px no-repeat;}
.sub_box img{border:none; width:235px; height:190px;}
#bd1lfimg{position:relative; width:235px; height:190px; overflow:hidden;}
#bd1lfimg div{width:100000px; margin-left:-4px;}
#bd1lfimg dl{width:235px; height:190px; position:relative; overflow:hidden; float:left;}
#bd1lfimg dt{width:235px; height:190px; position:absolute; left:0px; top:0px;}
#bd1lfimg dd{width:623px; height:40px; background:#000000; filter:alpha(Opacity=70); Opacity:0.7; position:absolute; left:0px; bottom:0px; padding:0 6px;}
#bd1lfimg dd h2{height:25px; padding:8px 0 4px 0; line-height:25px; overflow:hidden;}
#bd1lfimg dd h2 a{font-size:14px; font-weight:bold; color:#ffffff;}
#bd1lfimg dd a{color:#ffffff; text-decoration:none;}
#bd1lfimg dd a:hover{text-decoration:none; color:#cccccc;}
#bd1lfimg dd tt{color:#dddddd; line-height:1.2em; text-align:left; border:#FF0000 1px solid; width:100%; float:left;}
#bd1lfimg dd tt a:hover{text-decoration:underline;}.sub_nav{width:235px; height:25px; bottom:0px; position:absolute; color:#999999; z-index:200;}
.sub_no{height:25px; float:right;}
.sub_no li{display:block; width:25px; height:25px; float:left; overflow:hidden; line-height:25px; vertical-align:middle; text-align:center; background:#000000; filter:alpha(Opacity=70); Opacity:0.7; font-family:Arial; font-size:11px; color:#999999; cursor:pointer;}
.sub_no li.show{background:#ffffff; color:#000000;}
.sub_more{float:right; width:50px; height:25px; background:#000000; filter:alpha(Opacity=70); Opacity:0.7; color:#999999; text-align:center; line-height:25px;}
.sub_more a{color:#999999;}
.sub_more a:hover{color:#cccccc; text-decoration:none;}/*********图片切换 css定义***********/

focus.js文件内容如下:

//选择器
function $a(id,tag){var re=(id&&typeof id!="string")?id:document.getElementById(id);if(!tag){return re;}else{return re.getElementsByTagName(tag);}}//焦点滚动图 点击移动
function movec()
{var o=$a("bd1lfimg","");var oli=$a("bd1lfimg","dl");var oliw=oli[0].offsetWidth; //每次移动的宽度	 var ow=o.offsetWidth-2;var dnow=0; //当前位置	var olf=oliw-(ow-oliw+10)/2;o["scrollLeft"]=olf+(dnow*oliw);var rqbd=$a("bd1lfsj","ul")[0];var extime;<!--for(var i=1;i<oli.length;i++){rqbd.innerHTML+="<li>"+i+"</li>";}-->var rq=$a("bd1lfsj","li");for(var i=0;i<rq.length;i++){reg(i);};oli[dnow].className=rq[dnow].className="show";var wwww=setInterval(uu,2000);function reg(i){rq[i].οnclick=function(){oli[dnow].className=rq[dnow].className="";dnow=i;oli[dnow].className=rq[dnow].className="show";mv();}}function mv(){clearInterval(extime);clearInterval(wwww);extime=setInterval(bc,15);wwww=setInterval(uu,8000);}function bc(){var ns=((dnow*oliw+olf)-o["scrollLeft"]);var v=ns>0?Math.ceil(ns/10):Math.floor(ns/10);o["scrollLeft"]+=v;if(v==0){clearInterval(extime);oli[dnow].className=rq[dnow].className="show";v=null;}}function uu(){if(dnow<oli.length-2){oli[dnow].className=rq[dnow].className="";dnow++;oli[dnow].className=rq[dnow].className="show";}else{oli[dnow].className=rq[dnow].className="";dnow=0;oli[dnow].className=rq[dnow].className="show";}mv();}o.οnmοuseοver=function(){clearInterval(extime);clearInterval(wwww);}o.οnmοuseοut=function(){extime=setInterval(bc,15);wwww=setInterval(uu,8000);}
}

aspx页面中引入js和css文件,及div文件

<link href="JS/main.css" type="text/css" rel="stylesheet" />
<script src="JS/focus.js" type="text/javascript"></script><div id="flash"><div id="content"><div id="main2012"><div class="sub_box"><div id="p-select" class="sub_nav"><div class="sub_more"><a href="ItemsIndex/newsIndex.aspx?pmenuid=4
" οnfοcus="this.blur()" title="" style="font-family: Tahoma; font-size: 12px;" target="_blank">更多>></a></div><div class="sub_no" id="bd1lfsj"><ul><li class="show">1</li><li class="">2</li><li class="">3</li><li class="">4</li><liclass="">5</li><li class="">6</li></ul></div></div><div id="bd1lfimg"><div><dl class="show"></dl><dl class=""><dt><a href='<%=imgLink[0] %>' title="" target="_blank"><img src='<%=imgUrl[0]%>' alt=""></a></dt><dd><tt><a href='<%=imgLink[0] %>' target="_blank"><%=imgText[0] %></a></tt></dd></dl><dl class=""><dt><a href='<%=imgLink[1] %>' title="" target="_blank"><img src='<%=imgUrl[1]%>' alt=""></a></dt><dd><tt><a href='<%=imgLink[1] %>' target="_blank"><%=imgText[1] %></a></tt></dd></dl><dl class=""><dt><a href='<%=imgLink[2] %>' title="" target="_blank"><img src='<%=imgUrl[2]%>' alt=""></a></dt><dd><tt><a href='<%=imgLink[2] %>' target="_blank"><%=imgText[2] %></a></tt></dd></dl><dl class=""><dt><a href='<%=imgLink[3] %>' title="" target="_blank"><img src='<%=imgUrl[3]%>' alt=""></a></dt><dd><tt><a href='<%=imgLink[3] %>' target="_blank"><%=imgText[3] %></a></tt></dd></dl><dl class=""><dt><a href='<%=imgLink[4] %>' title="" target="_blank"><img src='<%=imgUrl[4]%>' alt=""></a></dt><dd><tt><a href='<%=imgLink[4] %>' target="_blank"><%=imgText[4] %></a></tt></dd></dl><dl class=""><dt><a href='<%=imgLink[5] %>' title="" target="_blank"><img src='<%=imgUrl[5]%>' alt=""></a></dt><dd><tt><a href='<%=imgLink[5] %>' target="_blank"><%=imgText[5] %></a></tt></dd></dl></div></div></div><script type="text/javascript">movec();</script></div></div></div>

上面aspx中的值来自后台cs文件

//图片链接新闻信息相关内容public string[] imgUrl = new string[6];public string[] imgText = new string[6];public string[] imgLink = new string[6];

             imgUrl = getFlashNewsImageUrl();imgText = getFlashNewsImageText();imgLink = getFlashNewsImageLink();public string[] getFlashNewsImageUrl(){Data dt = new Data();DataSet ds = dt.GetItemBytype();string[] news = new string[ds.Tables[0].Rows.Count];for (int i = 0; i < ds.Tables[0].Rows.Count; i++){string Item_url = ds.Tables[0].Rows[i]["p_pic"].ToString();//图片新闻路径news[i] = Item_url;}return news;}public string[] getFlashNewsImageText(){Data dt = new Data();DataSet ds = dt.GetItemBytype();string[] news = new string[ds.Tables[0].Rows.Count];for (int i = 0; i < ds.Tables[0].Rows.Count; i++){string newitem = ds.Tables[0].Rows[i]["p_name"].ToString();if (newitem.Length > 20){newitem = newitem.Substring(0, 16) + "...";}string Itemtitle = newitem;//图片新闻标题 itemtitlenews[i] = newitem;}return news;}public string[] getFlashNewsImageLink(){Data dt = new Data();DataSet ds = dt.GetItemBytype();string[] news = new string[ds.Tables[0].Rows.Count];for (int i = 0; i < ds.Tables[0].Rows.Count; i++){string Link = "ItemsContent/NewCont.aspx?nowmenuid=4&p_id=" + ds.Tables[0].Rows[i]["p_id"].ToString();//图片新闻链接地址news[i] = Link;}return news;}


PS:给大家推荐一个好的演示站点

1、http://www.chhua.com/myfocus/

这篇关于asp.net+js方式实现的幻灯图片效果展示的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/819004

相关文章

Flutter实现文字镂空效果的详细步骤

《Flutter实现文字镂空效果的详细步骤》:本文主要介绍如何使用Flutter实现文字镂空效果,包括创建基础应用结构、实现自定义绘制器、构建UI界面以及实现颜色选择按钮等步骤,并详细解析了混合模... 目录引言实现原理开始实现步骤1:创建基础应用结构步骤2:创建主屏幕步骤3:实现自定义绘制器步骤4:构建U

SpringBoot中四种AOP实战应用场景及代码实现

《SpringBoot中四种AOP实战应用场景及代码实现》面向切面编程(AOP)是Spring框架的核心功能之一,它通过预编译和运行期动态代理实现程序功能的统一维护,在SpringBoot应用中,AO... 目录引言场景一:日志记录与性能监控业务需求实现方案使用示例扩展:MDC实现请求跟踪场景二:权限控制与

Android实现定时任务的几种方式汇总(附源码)

《Android实现定时任务的几种方式汇总(附源码)》在Android应用中,定时任务(ScheduledTask)的需求几乎无处不在:从定时刷新数据、定时备份、定时推送通知,到夜间静默下载、循环执行... 目录一、项目介绍1. 背景与意义二、相关基础知识与系统约束三、方案一:Handler.postDel

在.NET平台使用C#为PDF添加各种类型的表单域的方法

《在.NET平台使用C#为PDF添加各种类型的表单域的方法》在日常办公系统开发中,涉及PDF处理相关的开发时,生成可填写的PDF表单是一种常见需求,与静态PDF不同,带有**表单域的文档支持用户直接在... 目录引言使用 PdfTextBoxField 添加文本输入域使用 PdfComboBoxField

gradle第三方Jar包依赖统一管理方式

《gradle第三方Jar包依赖统一管理方式》:本文主要介绍gradle第三方Jar包依赖统一管理方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录背景实现1.顶层模块build.gradle添加依赖管理插件2.顶层模块build.gradle添加所有管理依赖包

使用Python实现IP地址和端口状态检测与监控

《使用Python实现IP地址和端口状态检测与监控》在网络运维和服务器管理中,IP地址和端口的可用性监控是保障业务连续性的基础需求,本文将带你用Python从零打造一个高可用IP监控系统,感兴趣的小伙... 目录概述:为什么需要IP监控系统使用步骤说明1. 环境准备2. 系统部署3. 核心功能配置系统效果展

Python实现微信自动锁定工具

《Python实现微信自动锁定工具》在数字化办公时代,微信已成为职场沟通的重要工具,但临时离开时忘记锁屏可能导致敏感信息泄露,下面我们就来看看如何使用Python打造一个微信自动锁定工具吧... 目录引言:当微信隐私遇到自动化守护效果展示核心功能全景图技术亮点深度解析1. 无操作检测引擎2. 微信路径智能获

Python中pywin32 常用窗口操作的实现

《Python中pywin32常用窗口操作的实现》本文主要介绍了Python中pywin32常用窗口操作的实现,pywin32主要的作用是供Python开发者快速调用WindowsAPI的一个... 目录获取窗口句柄获取最前端窗口句柄获取指定坐标处的窗口根据窗口的完整标题匹配获取句柄根据窗口的类别匹配获取句

Linux之systemV共享内存方式

《Linux之systemV共享内存方式》:本文主要介绍Linux之systemV共享内存方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、工作原理二、系统调用接口1、申请共享内存(一)key的获取(二)共享内存的申请2、将共享内存段连接到进程地址空间3、将

Maven中引入 springboot 相关依赖的方式(最新推荐)

《Maven中引入springboot相关依赖的方式(最新推荐)》:本文主要介绍Maven中引入springboot相关依赖的方式(最新推荐),本文给大家介绍的非常详细,对大家的学习或工作具有... 目录Maven中引入 springboot 相关依赖的方式1. 不使用版本管理(不推荐)2、使用版本管理(推