JS實(shí)現(xiàn)圖片高亮展示效果實(shí)例
本文實(shí)例講述了JS實(shí)現(xiàn)圖片高亮展示效果的方法。分享給大家供大家參考,具體如下:
昨天朋友讓我?guī)椭鰝€(gè)圖片高亮展示的效果,雖然不難,不過滿有創(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="名稱1"><img onmouseover="gallery(this);" onmouseout="clearBg(this)" src="/images/artist//12053006018793_3.jpg" height="55" width="55" alt="名稱1"/><span></span></a></li>
<li><a href="#" title="名稱2"><img onmouseover="gallery(this);" onmouseout="clearBg(this)" src="/images/artist//12053006018793_3.jpg" height="55" width="55" alt="名稱2"/><span></span></a></li>
<li><a href="#" title="名稱3"><img onmouseover="gallery(this);" onmouseout="clearBg(this)" src="/images/artist//12053006018793_3.jpg" height="55" width="55" alt="名稱3"/><span></span></a></li>
<li><a href="#" title="名稱4"><img onmouseover="gallery(this);" onmouseout="clearBg(this)" src="/images/artist//12053006018793_3.jpg" height="55" width="55" alt="名稱4"/><span></span></a></li>
<li><a href="#" title="名稱5"><img onmouseover="gallery(this);" onmouseout="clearBg(this)" src="/images/artist//12053006018793_3.jpg" height="55" width="55" alt="名稱5"/><span></span></a></li>
<li><a href="#" title="名稱6"><img onmouseover="gallery(this);" onmouseout="clearBg(this)" src="/images/artist//12053006018793_3.jpg" height="55" width="55" alt="名稱6"/><span></span></a></li>
</ul>
<div id="trans"> </div>
<strong id="show_tit"> </strong>
</div>
</body>
</html>
剛開始因?yàn)闆]有完全明白設(shè)計(jì)意圖,陰差陽錯(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="名稱1"><img src="/images/artist//12053006018793_3.jpg" height="55"
width="55" alt="名稱1"/><span></span></a></li>
<li><a href="#" onmouseover="gallery(this);" title="名稱2"><img src="/images/artist//12053006018793_3.jpg" height="55"
width="55" alt="名稱2"/><span></span></a></li>
<li><a href="#" onmouseover="gallery(this);" title="名稱3"><img src="/images/artist//12053006018793_3.jpg" height="55"
width="55" alt="名稱3"/><span></span></a></li>
<li><a href="#" onmouseover="gallery(this);" title="名稱4"><img src="/images/artist//12053006018793_3.jpg" height="55"
width="55" alt="名稱4"/><span></span></a></li>
<li><a href="#" onmouseover="gallery(this);" title="名稱5"><img src="/images/artist//12053006018793_3.jpg" height="55"
width="55" alt="名稱5"/><span></span></a></li>
<li><a href="#" onmouseover="gallery(this);" title="名稱6"><img src="/images/artist//12053006018793_3.jpg" height="55"
width="55" alt="名稱6"/><span></span></a></li>
</ul>
<strong id="show_tit">這里顯示名字</strong>
</div>
</body>
</html>
希望本文所述對(duì)大家JavaScript程序設(shè)計(jì)有所幫助。
- js鼠標(biāo)點(diǎn)擊圖片切換效果實(shí)現(xiàn)代碼
- JS實(shí)現(xiàn)3D圖片旋轉(zhuǎn)展示效果代碼
- js帶縮略圖的圖片輪播效果代碼分享
- js鼠標(biāo)點(diǎn)擊圖片切換效果代碼分享
- js鋼琴按鈕波浪式圖片排列效果代碼分享
- js淡入淡出的圖片輪播效果代碼分享
- js圖片翻書效果代碼分享
- JS+CSS實(shí)現(xiàn)表格高亮的方法
- js 玩轉(zhuǎn)正則表達(dá)式之語法高亮
- 用JS將搜索的關(guān)鍵字高亮顯示實(shí)現(xiàn)代碼
- js正文內(nèi)容高亮效果的實(shí)現(xiàn)方法
- js 全兼容可高亮二級(jí)緩沖折疊菜單
相關(guān)文章
TypeScript在Vuex4中使用TS實(shí)戰(zhàn)分享
這篇文章主要介紹了TypeScript在Vuex4中使用TS實(shí)戰(zhàn)分享,vuex4類型?Api分析和vuex4實(shí)戰(zhàn)兩部分講述,需要的小伙伴可以參考一下2022-06-06
通過JavaScript使Div居中并隨網(wǎng)頁大小改變而改變
自己的頁面太難看了,要居中沒居中,要顏色沒顏色,但是無論是怎么樣都得使登錄的框居中吧,下面與大家分享下通過JavaScript可以簡(jiǎn)單的使Div在頁面上居中,隨著網(wǎng)頁大小的改變做出相應(yīng)的改變2013-06-06
每天一篇javascript學(xué)習(xí)小結(jié)(RegExp對(duì)象)
這篇文章主要介紹了javascript中的RegExp對(duì)象知識(shí)點(diǎn),對(duì)RegExp對(duì)象的基本使用方法,以及各種方法進(jìn)行整理,感興趣的小伙伴們可以參考一下2015-11-11
LayUi中接口傳數(shù)據(jù)成功,表格不顯示數(shù)據(jù)的解決方法
今天小編就為大家分享一篇LayUi中接口傳數(shù)據(jù)成功,表格不顯示數(shù)據(jù)的解決方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2018-08-08
Javascript對(duì)象Clone實(shí)例分析
這篇文章主要介紹了Javascript對(duì)象Clone用法,實(shí)例分析了javascript對(duì)象克隆的相關(guān)技巧,需要的朋友可以參考下2015-06-06
javascript與css3動(dòng)畫結(jié)合使用小結(jié)
本文給大家講述的是如何使用javascript結(jié)合CSS動(dòng)畫來實(shí)現(xiàn)一些占用資源更少,更優(yōu)化的動(dòng)畫效果,思路十分巧妙,這里推薦給小伙伴們參考下。2015-03-03
js 判斷一個(gè)數(shù)字是不是2的n次方冪的實(shí)例
下面小編就為大家分享一篇js 判斷一個(gè)數(shù)字是不是2的n次方冪的實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助2017-11-11
js中eval方法詳解之eval方法的初級(jí)應(yīng)用
js中eval()函數(shù)可計(jì)算某個(gè)字符串,下面這篇文章主要給大家介紹了關(guān)于js中eval方法詳解之eval方法的初級(jí)應(yīng)用的相關(guān)資料,文中通過實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下2023-01-01

