国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 編程 > JavaScript > 正文

JS實(shí)現(xiàn)圖片高亮展示效果實(shí)例

2019-11-20 11:10:54
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

本文實(shí)例講述了JS實(shí)現(xiàn)圖片高亮展示效果的方法。分享給大家供大家參考,具體如下:

昨天朋友讓我?guī)椭鰝€(gè)圖片高亮展示的效果,雖然不難,不過(guò)滿有創(chuàng)意的:

<!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>name</title><style type="text/css">*{}{margin:0; padding:0;}a img{}{border:none;}#imagesBox {}{ width:165px; height:110px; position:relative; left:100px; top:100px; z-index:1; border:1px solid black; background-color:white;}#trans{}{ width:165px; height:110px; position:absolute; left:0; top:0; z-index:2; display:none; opacity:0.5; filter:alpha(opacity=50); background-color:black;}#imagesBox li {}{ width:55px; height:55px; float:left; overflow:hidden;}#imagesBox li a,#imagesBox li img {}{ width:55px; height:55px; display:block; cursor:pointer;}#imagesBox li img{}{ position:relative;}#imagesBox strong{}{position:absolute;left:0; top:50%; margin-top:-7px; z-index:999; display:block; color:white; width:100%; height:15px; text-align:center; z-index:999;} </style><script type="text/javascript">  function gallery(obj){    var tit=obj.getAttribute("alt");      document.getElementById("show_tit").firstChild.nodeValue=tit;    document.getElementById("trans").style.display='block';    obj.style.zIndex="3";  }  function clearBg(obj){    document.getElementById("show_tit").firstChild.nodeValue="";    document.getElementById("trans").style.display='none';    obj.style.zIndex="1";  }</script></head><body><div id="imagesBox">   <ul>  <li><a href="#" title="名稱(chēng)1"><img onmouseover="gallery(this);" onmouseout="clearBg(this)" src="/images/artist//12053006018793_3.jpg" height="55" width="55" alt="名稱(chēng)1"/><span></span></a></li>  <li><a href="#" title="名稱(chēng)2"><img onmouseover="gallery(this);" onmouseout="clearBg(this)" src="/images/artist//12053006018793_3.jpg" height="55" width="55" alt="名稱(chēng)2"/><span></span></a></li>  <li><a href="#" title="名稱(chēng)3"><img onmouseover="gallery(this);" onmouseout="clearBg(this)" src="/images/artist//12053006018793_3.jpg" height="55" width="55" alt="名稱(chēng)3"/><span></span></a></li>  <li><a href="#" title="名稱(chēng)4"><img onmouseover="gallery(this);" onmouseout="clearBg(this)" src="/images/artist//12053006018793_3.jpg" height="55" width="55" alt="名稱(chēng)4"/><span></span></a></li>  <li><a href="#" title="名稱(chēng)5"><img onmouseover="gallery(this);" onmouseout="clearBg(this)" src="/images/artist//12053006018793_3.jpg" height="55" width="55" alt="名稱(chēng)5"/><span></span></a></li>  <li><a href="#" title="名稱(chēng)6"><img onmouseover="gallery(this);" onmouseout="clearBg(this)" src="/images/artist//12053006018793_3.jpg" height="55" width="55" alt="名稱(chēng)6"/><span></span></a></li> </ul><div id="trans"> </div><strong id="show_tit"> </strong></div></body></html>

剛開(kāi)始因?yàn)闆](méi)有完全明白設(shè)計(jì)意圖,陰差陽(yáng)錯(cuò)的做了個(gè)這樣的效果:

<!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>name</title><style type="text/css">*{margin:0; padding:0;}a img{border:none;}#imagesBox { width:165px; height:100px; position:relative; left:100px; top:100px;}#imagesBox li { width:55px; height:55px; float:left; overflow:hidden; position:relative;}#imagesBox li img { width:55px; height:55px; position:relative; z-index:2; }#imagesBox li span { line-height:100px; background:#000; position:absolute; top:0; left:0; z-index:3; opacity:0.5; filter:alpha(opacity=50); display:block; width:55px; height:55px;}#imagesBox li a:hover span{display:none;} #imagesBox strong{position:absolute;left:0; top:50%; margin-top:-7px; z-index:999; display:block; color:white; width:100%; height:15px; text-align:center;} </style><script type="text/javascript">  function gallery(obj){    var tit=obj.getAttribute("title");      document.getElementById("show_tit").firstChild.nodeValue=tit;    document.getElementById("imagesBox").onmouseout=function(){document.getElementById("show_tit").firstChild.nodeValue="這里顯示名字"};  }</script></head><body><div id="imagesBox"> <ul>  <li><a href="#" onmouseover="gallery(this);" title="名稱(chēng)1"><img src="/images/artist//12053006018793_3.jpg" height="55" width="55" alt="名稱(chēng)1"/><span></span></a></li>  <li><a href="#" onmouseover="gallery(this);" title="名稱(chēng)2"><img src="/images/artist//12053006018793_3.jpg" height="55" width="55" alt="名稱(chēng)2"/><span></span></a></li>  <li><a href="#" onmouseover="gallery(this);" title="名稱(chēng)3"><img src="/images/artist//12053006018793_3.jpg" height="55" width="55" alt="名稱(chēng)3"/><span></span></a></li>  <li><a href="#" onmouseover="gallery(this);" title="名稱(chēng)4"><img src="/images/artist//12053006018793_3.jpg" height="55" width="55" alt="名稱(chēng)4"/><span></span></a></li>  <li><a href="#" onmouseover="gallery(this);" title="名稱(chēng)5"><img src="/images/artist//12053006018793_3.jpg" height="55" width="55" alt="名稱(chēng)5"/><span></span></a></li>  <li><a href="#" onmouseover="gallery(this);" title="名稱(chēng)6"><img src="/images/artist//12053006018793_3.jpg" height="55" width="55" alt="名稱(chēng)6"/><span></span></a></li> </ul> <strong id="show_tit">這里顯示名字</strong></div></body></html>

希望本文所述對(duì)大家JavaScript程序設(shè)計(jì)有所幫助。

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 陆丰市| 红安县| 乾安县| 孟州市| 岳阳县| 黄平县| 内江市| 色达县| 七台河市| 岱山县| 玉龙| 北流市| 托克逊县| 北碚区| 朔州市| 台前县| 宣汉县| 霍林郭勒市| 嘉祥县| 屏东市| 绥中县| 竹山县| 灌南县| 民权县| 鹤岗市| 宕昌县| 博罗县| 罗山县| 张家川| 象山县| 民县| 南通市| 陵水| 河池市| 华安县| 扎囊县| 南涧| 和政县| 昆明市| 扎鲁特旗| 北碚区|