代码驿站移动版
频道导航
HTML/Xhtml
CSS
JavaScript
HTML5
PHP教程
ASP.NET
正则表达式
AJAX
ThinkPHP
Yii
MySQL
MariaDB
Oracle
MongoDB
Redis
DedeCMS
PHPCMS
帝国CMS
WordPress
Discuz
其它CMS
Zend Studio
Sublime
Notepad
Dreamweaver
Windows
Linux
Nginx
Apache
IIS
CentOS
Ubuntu
Debian
网站优化
工具资源
PHP源码
ASP.NET源码
其它源码
图标素材
按钮素材
字体素材
DedeCMS模板
帝国CMS模板
PHPCMS模板
WordPress模板
Discuz!模板
单页模板
开发软件下载
服务器软件下载
广告投放
联系我们
版权申明
软件编程
网页前端
移动开发
数据库
服务器
脚本语言
PHP代码
JAVA代码
Python代码
Android代码
当前位置:
主页
>
网页前端
>
JavaScript代码
>
一个特帅的展示图片的js+css
时间:2022-07-10 09:38:35 | 栏目:
JavaScript代码
| 点击:次
<P><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML lang=it dir=ltr xml:lang="it" xmlns="http://www.w3.org/1999/xhtml"><HEAD><TITLE>CSS+JS控制图片展示</TITLE><STYLE>BODY { PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; FONT: 70% </P> <P>Verdana, Geneva, Arial, Helvetica, sans-serif; COLOR: #000; PADDING-TOP: 0px; TEXT-</P> <P>ALIGN: center}#outer { PADDING-RIGHT: 0px; PADDING-LEFT: 0px; BACKGROUND: url(/images/bg-outer.gif) </P> <P>repeat-y center top; PADDING-BOTTOM: 0px; MARGIN: 0px auto; WIDTH: 780px; PADDING-</P> <P>TOP: 0px; TEXT-ALIGN: left}#wrapper { BACKGROUND: #fff; MARGIN: 0px 4px}#content { PADDING-RIGHT: 0px; PADDING-LEFT: 0px; MIN-HEIGHT: 400px; PADDING-BOTTOM: 20px; </P> <P>MARGIN: 20px 30px; PADDING-TOP: 0px; POSITION: relative}#focus { BORDER-RIGHT: #ccc 2px solid; PADDING-RIGHT: 0px; BORDER-TOP: #ccc 2px solid; </P> <P>PADDING-LEFT: 0px; MIN-HEIGHT: 188px; BACKGROUND: url(/images/tile.gif) #eee repeat</P> <P>-y left top; PADDING-BOTTOM: 10px; MARGIN: 25px 0px 30px; BORDER-LEFT: #ccc 2px </P> <P>solid; WIDTH: 100%; PADDING-TOP: 15px; BORDER-BOTTOM: #ccc 2px solid; POSITION: </P> <P>relative; HEIGHT: 188px}#beni { PADDING-RIGHT: 0px; PADDING-LEFT: 0px; LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; </P> <P>WIDTH: 250px; PADDING-TOP: 0px; LIST-STYLE-TYPE: none; POSITION: absolute; TOP: 15px}#beni LI { BORDER-TOP: #fff 1px solid; FONT-SIZE: 12px; FLOAT: left; WIDTH: 250px; TEXT-</P> <P>INDENT: 24px; LINE-HEIGHT: 26px}#beni LI.first { BORDER-TOP: 0px}#beni LI A { BORDER-RIGHT: 0px; PADDING-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: block; PADDING-</P> <P>LEFT: 0px; FONT-WEIGHT: bold; BACKGROUND: #eee; PADDING-BOTTOM: 0px; MARGIN: 0px; </P> <P>BORDER-LEFT: 0px; PADDING-TOP: 0px; BORDER-BOTTOM: 0px; TEXT-DECORATION: none}#beni LI A:hover { BACKGROUND: #f9f9f9}</STYLE><SCRIPT type="text/javascript">function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { oldonload(); func(); } }}</P> <P>function insertAfter(newelement,existingelement) { var parentelement = existingelement.parentNode; if (parentelement.lastChild == existingelement) { return parentelement.appendChild(newelement); } else { return parentelement.insertBefore(newelement,existingelement.nextSibling); }}</P> <P>function makeSlideshow(details,coords,linkholder) { if (!document.getElementById) return false; if (!document.getElementById(linkholder)) return false; var pane = document.createElement('div'); pane.style.width = details['width']; pane.style.height = details['height']; pane.style.overflow = 'hidden'; //pane.className = 'descrizione'; pane.style.position = 'relative'; pane.style.top = '0px'; pane.style.left = '270px'; pane.setAttribute('id','descrizione'); var pic = document.createElement('img'); pic.setAttribute('id',details['id']); pic.setAttribute('src',details['image']); pic.setAttribute('alt',''); pic.style.position = 'absolute'; pane.appendChild(pic); var l_beni = document.getElementById(linkholder); l_beni.parentNode.insertBefore(pane,l_beni); var lnks = l_beni.getElementsByTagName('a'); for (var i=0;i<lnks.length;i++) { var linktext = lnks[i].childNodes[0].nodeValue; if (coords[linktext]) { lnks[i].elementId = details['id']; lnks[i].x = coords[linktext][0]; lnks[i].y = coords[linktext][1]; lnks[i].sliding = null; lnks[i].onmouseover = function() { slideElement(this.elementId,this.x,this.y,6); } lnks[i].onfocus = lnks[i].onmouseover; } }}</P> <P>function slideElement(elementId,x,y,inc) { if (!document.getElementById) return false; if (!document.getElementById(elementId)) return false; var element = document.getElementById(elementId); if (element.sliding) clearTimeout(element.sliding); if (!element.xpos) element.xpos = 0; if (!element.ypos) element.ypos = 0; if (element.xpos == x && element.ypos == y) return true; if (element.xpos > x) { var dist = Math.ceil((element.xpos-x)/inc); element.xpos = element.xpos - dist; } if (element.xpos < x) { var dist = Math.ceil((x-element.xpos)/inc); element.xpos = element.xpos + dist; } if (element.ypos > y) { var dist = Math.ceil((element.ypos-y)/inc); element.ypos = element.ypos - dist; } if (element.ypos < y) { var dist = Math.ceil((y-element.ypos)/inc); element.ypos = element.ypos + dist; } element.style.left = element.xpos+'px'; element.style.top = element.ypos+'px'; element.sliding = setTimeout('slideElement</P> <P>("'+elementId+'",'+x+','+y+','+inc+')',10);}</P> <P>/* Focus Beni */addLoadEvent(showbeni);function showbeni() { if (!document.getElementById) return false; if (!document.getElementById('beni')) return false; var panel_details = new Array(); panel_details['id'] = 'pic'; panel_details['image'] = 'http://www.mhcy.net/html/css+js_photo/images/focus.jpg'; panel_details['width'] = '420px'; panel_details['height'] = '188px'; var coords = new Array(); coords['default'] = new Array(0,0); coords['Opere e oggetti d\'arte'] = new Array(0,-188); coords['Architetture'] = new Array(0, -376); coords['Reperti archeologici'] = new Array(0,-564); coords['Stampe e matrici di incisione'] = new Array(0,-752); coords['Fotografie'] = new Array(0,-940); coords['Beni etnoantropologici'] = new Array(0,-1128); var linkholder = 'beni'; makeSlideshow(panel_details,coords,linkholder);}</SCRIPT></HEAD></P> <P><BODY id=home><DIV id=outer><DIV id=wrapper> <DIV id=content> <DIV id=focus> <UL id=beni> <LI class=first><A href="#">Opere e oggetti d'arte</A></LI> <LI><A href="#">Architetture</A></LI> <LI><A href="#">Reperti archeologici</A></LI> <LI><A href="#">Stampe e matrici di incisione</A></LI> <LI><A href="#">Fotografie</A></LI> <LI><A href="#">Beni etnoantropologici</A></LI> </UL> </DIV> </DIV></DIV></DIV></BODY></HTML></P>
[Ctrl+A 全选 注:
引入外部Js需再刷新一下页面才能执行
]
您可能感兴趣的文章:
url传递的参数值中包含&时,url自动截断问题的解决方法
javascript上下左右定时滚动插件
JavaScript常见事件处理程序实例总结
Javascript的匿名函数小结
Javascript别踩白块儿(钢琴块儿)小游戏实现代码
相关文章
11-27
Javascript实例教程(19) 使用HoTMetal(2)
11-23
Webpack中loader打包各种文件的方法实例
11-08
兼容浏览器的js事件绑定函数(详解)
10-05
javascript判断图片是否加载完成的方法推荐
11-22
在javascript中执行任意html代码的方法示例解读
JQuery
VUE
AngularJS
MSSql
MySQL
MongoDB
Redis
Linux
Tomcat
Nginx
网站首页
广告投放
联系我们
版权申明
联系站长