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

相关文章

Python实现终端清屏的几种方式详解

《Python实现终端清屏的几种方式详解》在使用Python进行终端交互式编程时,我们经常需要清空当前终端屏幕的内容,本文为大家整理了几种常见的实现方法,有需要的小伙伴可以参考下... 目录方法一:使用 `os` 模块调用系统命令方法二:使用 `subprocess` 模块执行命令方法三:打印多个换行符模拟

SpringBoot+EasyPOI轻松实现Excel和Word导出PDF

《SpringBoot+EasyPOI轻松实现Excel和Word导出PDF》在企业级开发中,将Excel和Word文档导出为PDF是常见需求,本文将结合​​EasyPOI和​​Aspose系列工具实... 目录一、环境准备与依赖配置1.1 方案选型1.2 依赖配置(商业库方案)二、Excel 导出 PDF

Python实现MQTT通信的示例代码

《Python实现MQTT通信的示例代码》本文主要介绍了Python实现MQTT通信的示例代码,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一... 目录1. 安装paho-mqtt库‌2. 搭建MQTT代理服务器(Broker)‌‌3. pytho

使用zip4j实现Java中的ZIP文件加密压缩的操作方法

《使用zip4j实现Java中的ZIP文件加密压缩的操作方法》本文介绍如何通过Maven集成zip4j1.3.2库创建带密码保护的ZIP文件,涵盖依赖配置、代码示例及加密原理,确保数据安全性,感兴趣的... 目录1. zip4j库介绍和版本1.1 zip4j库概述1.2 zip4j的版本演变1.3 zip4

RabbitMQ消息总线方式刷新配置服务全过程

《RabbitMQ消息总线方式刷新配置服务全过程》SpringCloudBus通过消息总线与MQ实现微服务配置统一刷新,结合GitWebhooks自动触发更新,避免手动重启,提升效率与可靠性,适用于配... 目录前言介绍环境准备代码示例测试验证总结前言介绍在微服务架构中,为了更方便的向微服务实例广播消息,

SpringBoot中六种批量更新Mysql的方式效率对比分析

《SpringBoot中六种批量更新Mysql的方式效率对比分析》文章比较了MySQL大数据量批量更新的多种方法,指出REPLACEINTO和ONDUPLICATEKEY效率最高但存在数据风险,MyB... 目录效率比较测试结构数据库初始化测试数据批量修改方案第一种 for第二种 case when第三种

python生成随机唯一id的几种实现方法

《python生成随机唯一id的几种实现方法》在Python中生成随机唯一ID有多种方法,根据不同的需求场景可以选择最适合的方案,文中通过示例代码介绍的非常详细,需要的朋友们下面随着小编来一起学习学习... 目录方法 1:使用 UUID 模块(推荐)方法 2:使用 Secrets 模块(安全敏感场景)方法

Spring StateMachine实现状态机使用示例详解

《SpringStateMachine实现状态机使用示例详解》本文介绍SpringStateMachine实现状态机的步骤,包括依赖导入、枚举定义、状态转移规则配置、上下文管理及服务调用示例,重点解... 目录什么是状态机使用示例什么是状态机状态机是计算机科学中的​​核心建模工具​​,用于描述对象在其生命

Spring Boot 结合 WxJava 实现文章上传微信公众号草稿箱与群发

《SpringBoot结合WxJava实现文章上传微信公众号草稿箱与群发》本文将详细介绍如何使用SpringBoot框架结合WxJava开发工具包,实现文章上传到微信公众号草稿箱以及群发功能,... 目录一、项目环境准备1.1 开发环境1.2 微信公众号准备二、Spring Boot 项目搭建2.1 创建

IntelliJ IDEA2025创建SpringBoot项目的实现步骤

《IntelliJIDEA2025创建SpringBoot项目的实现步骤》本文主要介绍了IntelliJIDEA2025创建SpringBoot项目的实现步骤,文中通过示例代码介绍的非常详细,对大家... 目录一、创建 Spring Boot 项目1. 新建项目2. 基础配置3. 选择依赖4. 生成项目5.