您好,登錄后才能下訂單哦!
這篇文章主要講解了js仿搜狐視頻記錄片列表的代碼詳解,內容清晰明了,對此有興趣的小伙伴可以學習一下,相信大家閱讀完之后會有幫助。
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>無標題文檔</title> <style> *{margin:0;padding:0;} ul{list-style:none;} #list{width:300px;height:500px;margin:40px auto;border:1px solid #ccc;} #list .lis{width:300px;height:auto;line-height:50px;border-bottom:1px solid #ccc;float:left;} #list .lis ul {width:300px;height:50px;} #list .lis ul li {width:300px;height:50px;line-height:50px;display:none;} #list .lis ul li span {display:inline-block;margin:10px;width:30px;height:30px;text-align:center;line-height:30px;background:#3366FF;color:#fff;} #list .lis ul li p {display:inline-block;width:150px;height:50px;line-height:30px;} #list .lis ul li div.index {float:left;width:50px;height:150px;display:line-block;} #list .lis ul li div.index span.blur {font-weight:bold;background:#fff;color:blue;} #list .lis ul li img {width:120px;height:120px;margin:15px;float:left;display:inline-block;} #list .lis ul li div.desc {position:relative;float:left;width:100px;height:150px;} #list .lis ul li div.desc p {position:absolute;left:0px;top:20px;color:#000;width:100px;height:30px;line-height:30px;} #list .lis ul li div.desc a {width:60px;height:30px;position:absolute;bottom:5px;right:5px;text-decoration:none;background:blue;color:#fff;font-size:20px;padding:5px;border-radius:8px;dispaly:inline-block;line-height:30px;text-align:center;} #list .lis ul li:first-child{display:block;} </style> <script> window.onload = function (){ var oUl = document.getElementById('list'); var aUl = oUl.getElementsByTagName('ul'); var lis = oUl.getElementsByClassName('lis'); var arr = [ ['小兵張嘎', 'img/1.png', '小兵張嘎的簡介'], ['大耳朵圖圖', 'img/2.png', '大耳朵圖圖的簡介'], ['海賊王', 'img/3.png', '海賊王的簡介'], ['火影忍者', 'img/4.png', '火影忍者的簡介'], ['奧特曼', 'img/1.png', '奧特曼的簡介'], ['熊出沒', 'img/2.png', '熊出沒的簡介'], ['小鬼到家', 'img/3.png', '小鬼到家的簡介'], ['游戲王', 'img/4.png', '游戲王的簡介'], ['哈利波特', 'img/1.png', '哈利波特的簡介'], ]; for ( var i = 0; i < aUl.length; i ++ ) { var aLi = aUl[i].getElementsByTagName('li'); aLi[0].getElementsByTagName('span')[0].innerHTML = i + 1; aLi[0].getElementsByTagName('p')[0].innerHTML = arr[i][0]; var aSpan = aLi[1].getElementsByTagName('span'); var index = i + 1; for ( var j = 0; j < aSpan.length; j ++) { aSpan[j].innerHTML = index++; } aLi[1].getElementsByTagName('img')[0].src = arr[i][1]; aLi[1].getElementsByTagName('p')[0].innerHTML = arr[i][2]; } for ( var i = 0; i < aUl.length; i ++ ) { aUl[i].onmouseover = function () { this.getElementsByTagName('li')[0].style.display = 'none'; //this.style.cssText = 'height:150px;line-height:150px;'; this.getElementsByTagName('li')[1].style.display = 'block'; } aUl[i].onmouseout = function () { this.getElementsByTagName('li')[1].style.display = 'none'; this.getElementsByTagName('li')[0].style.display = 'block'; } } } </script> </head> <body> <ul id="list"> <li class="lis"> <ul> <li> <span></span> <p></p> </li> <li> <div class="index"> <span></span> <span class="blur"></span> <span class="blur"></span> </div> <img/> <div class="desc"> <p></p> <a href="javascript:;">播放</a> </div> </li> </ul> </li> <li class="lis"> <ul> <li> <span></span> <p></p> </li> <li> <div class="index"> <span></span> <span class="blur"></span> <span class="blur"></span> </div> <img/> <div class="desc"> <p></p> <a href="javascript:;">播放</a> </div> </li> </ul> </li> <li class="lis"> <ul> <li> <span></span> <p></p> </li> <li> <div class="index"> <span></span> <span class="blur"></span> <span class="blur"></span> </div> <img/> <div class="desc"> <p></p> <a href="javascript:;">播放</a> </div> </li> </ul> </li> <li class="lis"> <ul> <li> <span></span> <p></p> </li> <li> <div class="index"> <span></span> <span class="blur"></span> <span class="blur"></span> </div> <img/> <div class="desc"> <p></p> <a href="javascript:;">播放</a> </div> </li> </ul> </li> <li class="lis"> <ul> <li> <span></span> <p></p> </li> <li> <div class="index"> <span></span> <span class="blur"></span> <span class="blur"></span> </div> <img/> <div class="desc"> <p></p> <a href="javascript:;">播放</a> </div> </li> </ul> </li> <li class="lis"> <ul> <li> <span></span> <p></p> </li> <li> <div class="index"> <span></span> <span class="blur"></span> <span class="blur"></span> </div> <img/> <div class="desc"> <p></p> <a href="javascript:;">播放</a> </div> </li> </ul> </li> <li class="lis"> <ul> <li> <span></span> <p></p> </li> <li> <div class="index"> <span></span> <span class="blur"></span> <span class="blur"></span> </div> <img/> <div class="desc"> <p></p> <a href="javascript:;">播放</a> </div> </li> </ul> </li> <li class="lis"> <ul> <li> <span></span> <p></p> </li> <li> <div class="index"> <span></span> <span class="blur"></span> <span class="blur"></span> </div> <img/> <div class="desc"> <p></p> <a href="javascript:;">播放</a> </div> </li> </ul> </li> <li class="lis"> <ul> <li> <span></span> <p></p> </li> <li> <div class="index"> <span></span> <span class="blur"></span> <span class="blur"></span> </div> <img/> <div class="desc"> <p></p> <a href="javascript:;">播放</a> </div> </li> </ul> </li> </ul> </body> </html>
看完上述內容,是不是對js仿搜狐視頻記錄片列表的代碼詳解有進一步的了解,如果還想學習更多內容,歡迎關注億速云行業資訊頻道。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。