完全用CSS+Javascript制作的网页相册。
<!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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>相册 v4.0</title> <style> *{ margin:0; padding:0; list-style:none} body{ font-family:Arial, Helvetica, sans-serif; font-size:12px; line-height:1.8;} img{ display:block; border:0;} h1,h2{ background:#85B829; line-height:2.5; font-size:14px; padding-left:10px; color:#fff;} #pics{ border-left:3px solid #468C50; border-right:3px solid #99CC99; background:#B5DF63; float:left; width:750px;} li{ float:left;} a{ display:block; background:#fff; border:1px solid #A4D742; text-align:center; color:#598628; text-decoration:none; padding:5px; margin:10px;} a:hover,a:active{ background:#99CC33; border:1px solid #85B829; border-left:1px solid #fff; border-top:1px solid #fff; color:#fff} #showpic{ border:1px solid #85B829; padding:5px; display:none; clear:left; background:#FFF; text-align: center} ul,#showpic{ margin:10px;} h2{ color:#598628; background:none; text-align:left} #showpic img{ margin:auto} </style> </head> <body> <div id="pics"> <h1>我的动物园</h1> <ul> <li><a href="http://www.itjxue.com/files/090316/1_195857.jpg" title="四只长颈鹿"><img src="http://www.itjxue.com/files/090316/1_200223.jpg" />长颈鹿</a></li> <li><a href="http://www.itjxue.com/files/090316/1_195911.jpg" title="绿色的小青蛙"><img src="http://www.itjxue.com/files/090316/1_200235.jpg" />青蛙</a></li> <li><a href="http://www.itjxue.com/files/090316/1_195923.jpg" title="小狗狗会汪汪"><img src="http://www.itjxue.com/files/090316/1_200243.jpg" />小狗狗</a></li> <li><a href="http://www.itjxue.com/files/090316/1_195937.jpg" title="小老鼠兄弟"><img src="http://www.itjxue.com/files/090316/1_200255.jpg" />鼠小弟</a></li> <li><a href="http://www.itjxue.com/files/090316/1_195953.jpg" title="烫发的白天鹅"><img src="http://www.itjxue.com/files/090316/1_200306.jpg" />白天鹅</a></li> <li><a href="http://www.itjxue.com/files/090316/1_200004.jpg" title="鹦鹉夫妇"><img src="http://www.itjxue.com/files/090316/1_200320.jpg" />鹦鹉</a></li> <li><a href="http://www.itjxue.com/files/090316/1_200022.jpg" title="北方的狼"><img src="http://www.itjxue.com/files/090316/1_200330.jpg" />狼</a></li> <li><a href="http://www.itjxue.com/files/090316/1_200039.jpg" title="警觉中的斑马"><img src="http://www.itjxue.com/files/090316/1_200340.jpg" />斑马</a></li> <li><a href="http://www.itjxue.com/files/090316/1_200053.jpg" title="绿色的鸟"><img src="http://www.itjxue.com/files/090316/1_200348.jpg" />绿色的鸟</a></li> <li><a href="http://www.itjxue.com/files/090316/1_200112.jpg" title="金黄色的小金鱼"><img src="http://www.itjxue.com/files/090316/1_200401.jpg" />小金鱼</a></li> </ul> </div> <script language="javascript"> function setDiv(){ var pics = document.getElementById("pics"); var showpic = document.createElement("div"); showpic.setAttribute("id", "showpic"); pics.appendChild(showpic); showpic.appendChild(document.createElement("h2")); showpic.appendChild(document.createElement("img")); var links = pics.getElementsByTagName("a"); for(var k=0; k<links.length; k++){ links[k].onclick = function(){ return showPic(this); } } } function showPic(pic){ var showpic = document.getElementById("showpic"); showpic.style.display = "block"; showpic.getElementsByTagName("h2")[0].innerHTML = pic.title; showpic.getElementsByTagName("img")[0].setAttribute("src", pic.href); return false; } window.onload = setDiv; </script> </body> </html>
[ 提示:你可先修改部分代码,再按Ctrl+A 全部选择 ]