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

相关文章

基于SpringBoot+Mybatis实现Mysql分表

《基于SpringBoot+Mybatis实现Mysql分表》这篇文章主要为大家详细介绍了基于SpringBoot+Mybatis实现Mysql分表的相关知识,文中的示例代码讲解详细,感兴趣的小伙伴可... 目录基本思路定义注解创建ThreadLocal创建拦截器业务处理基本思路1.根据创建时间字段按年进

Win11安装PostgreSQL数据库的两种方式详细步骤

《Win11安装PostgreSQL数据库的两种方式详细步骤》PostgreSQL是备受业界青睐的关系型数据库,尤其是在地理空间和移动领域,:本文主要介绍Win11安装PostgreSQL数据库的... 目录一、exe文件安装 (推荐)下载安装包1. 选择操作系统2. 跳转到EDB(PostgreSQL 的

SpringBoot3实现Gzip压缩优化的技术指南

《SpringBoot3实现Gzip压缩优化的技术指南》随着Web应用的用户量和数据量增加,网络带宽和页面加载速度逐渐成为瓶颈,为了减少数据传输量,提高用户体验,我们可以使用Gzip压缩HTTP响应,... 目录1、简述2、配置2.1 添加依赖2.2 配置 Gzip 压缩3、服务端应用4、前端应用4.1 N

SpringBoot实现数据库读写分离的3种方法小结

《SpringBoot实现数据库读写分离的3种方法小结》为了提高系统的读写性能和可用性,读写分离是一种经典的数据库架构模式,在SpringBoot应用中,有多种方式可以实现数据库读写分离,本文将介绍三... 目录一、数据库读写分离概述二、方案一:基于AbstractRoutingDataSource实现动态

Python FastAPI+Celery+RabbitMQ实现分布式图片水印处理系统

《PythonFastAPI+Celery+RabbitMQ实现分布式图片水印处理系统》这篇文章主要为大家详细介绍了PythonFastAPI如何结合Celery以及RabbitMQ实现简单的分布式... 实现思路FastAPI 服务器Celery 任务队列RabbitMQ 作为消息代理定时任务处理完整

Java枚举类实现Key-Value映射的多种实现方式

《Java枚举类实现Key-Value映射的多种实现方式》在Java开发中,枚举(Enum)是一种特殊的类,本文将详细介绍Java枚举类实现key-value映射的多种方式,有需要的小伙伴可以根据需要... 目录前言一、基础实现方式1.1 为枚举添加属性和构造方法二、http://www.cppcns.co

使用Python实现快速搭建本地HTTP服务器

《使用Python实现快速搭建本地HTTP服务器》:本文主要介绍如何使用Python快速搭建本地HTTP服务器,轻松实现一键HTTP文件共享,同时结合二维码技术,让访问更简单,感兴趣的小伙伴可以了... 目录1. 概述2. 快速搭建 HTTP 文件共享服务2.1 核心思路2.2 代码实现2.3 代码解读3.

使用C#代码在PDF文档中添加、删除和替换图片

《使用C#代码在PDF文档中添加、删除和替换图片》在当今数字化文档处理场景中,动态操作PDF文档中的图像已成为企业级应用开发的核心需求之一,本文将介绍如何在.NET平台使用C#代码在PDF文档中添加、... 目录引言用C#添加图片到PDF文档用C#删除PDF文档中的图片用C#替换PDF文档中的图片引言在当

详解C#如何提取PDF文档中的图片

《详解C#如何提取PDF文档中的图片》提取图片可以将这些图像资源进行单独保存,方便后续在不同的项目中使用,下面我们就来看看如何使用C#通过代码从PDF文档中提取图片吧... 当 PDF 文件中包含有价值的图片,如艺术画作、设计素材、报告图表等,提取图片可以将这些图像资源进行单独保存,方便后续在不同的项目中使

MySQL双主搭建+keepalived高可用的实现

《MySQL双主搭建+keepalived高可用的实现》本文主要介绍了MySQL双主搭建+keepalived高可用的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,... 目录一、测试环境准备二、主从搭建1.创建复制用户2.创建复制关系3.开启复制,确认复制是否成功4.同