HTML+CSS+JS阶段性测试项目-抽奖

渲科

共 1720字,需浏览 4分钟

 ·

2021-10-28 22:39

项目截图:

1.初始页面:

c75e98fee39e0cfa05f3df64ad419dbd.webp

2.点击抽奖弹窗!

58440b158161571f8da45f42bcd9c3e5.webp

3.抽过奖的红包!

a9aa964c6e795df5ef51edf02ab9a0bc.webp

4.再次点击抽过奖的红包!

7297ab620f8cdf22e0f06486175f654c.webp

项目体验地址:http://47.105.32.145:56005

HTML源代码:

<html>  <head>    <meta charset="utf-8">    <link rel="stylesheet" type="text/css" href="css/main.css"/>    <title>抽奖title>  head>  <body>    <div id="div_bg">      <div class="container">
<table border="1" cellspacing="0" cellpadding="0"> <tr> <td><img class="image" src="./img/wc.png">td> <td><img class="image" src="./img/wc.png">td> <td><img class="image" src="./img/wc.png">td> <td><img class="image" src="./img/wc.png">td> <td><img class="image" src="./img/wc.png">td> <td><img class="image" src="./img/wc.png">td> <td><img class="image" src="./img/wc.png">td> <td><img class="image" src="./img/wc.png">td> tr> <tr> <td><img class="image" src="./img/wc.png">td> <td><img class="image" src="./img/wc.png">td> <td><img class="image" src="./img/wc.png">td> <td><img class="image" src="./img/wc.png">td> <td><img class="image" src="./img/wc.png">td> <td><img class="image" src="./img/wc.png">td> <td><img class="image" src="./img/wc.png">td> <td><img class="image" src="./img/wc.png">td> tr> <tr> <td><img class="image" src="./img/wc.png">td> <td><img class="image" src="./img/wc.png">td> <td><img class="image" src="./img/wc.png">td> <td><img class="image" src="./img/wc.png">td> <td><img class="image" src="./img/wc.png">td> <td><img class="image" src="./img/wc.png">td> <td><img class="image" src="./img/wc.png">td> <td><img class="image" src="./img/wc.png">td> tr> <tr> <td><img class="image" src="./img/wc.png">td> <td><img class="image" src="./img/wc.png">td> <td><img class="image" src="./img/wc.png">td> <td><img class="image" src="./img/wc.png">td> <td><img class="image" src="./img/wc.png">td> <td><img class="image" src="./img/wc.png">td> <td><img class="image" src="./img/wc.png">td> <td><img class="image" src="./img/wc.png">td> tr> <tr> <td><img class="image" src="./img/wc.png">td> <td><img class="image" src="./img/wc.png">td> <td><img class="image" src="./img/wc.png">td> <td><img class="image" src="./img/wc.png">td> <td><img class="image" src="./img/wc.png">td> <td><img class="image" src="./img/wc.png">td> <td><img class="image" src="./img/wc.png">td> <td><img class="image" src="./img/wc.png">td> tr>
table> div> div> body> <script src="js/index.js" type="text/javascript" charset="utf-8">script>html>

CSS源代码:

/* 把我们所有标签的内外边距清零 */* {  margin: 0;  padding: 0;  /* css3盒子模型 */  box-sizing: border-box;  clear: both;}
.container { width: 50%; position: relative; margin: 0 auto; padding: 200px 15px; box-sizing: border-box}
#div_bg { width: 100%; height: 1000px; background-image: url(../img/bg.jpg); background-size: 100% 1080px;}
.image { width: 54px; height: 84px;}
td { width: 100px; height: 100px; background-color: antiquewhite; text-align: center; opacity: 0.6;}

JS源代码:

var tds = document.getElementsByTagName('td');var imgs = document.getElementsByClassName('image');for (var i = 0; i < imgs.length; i++) {  imgs[i].outed = false;  BindEvent(i, imgs[i]);}
function BindEvent(index, img) { img.onclick = () => { if (!img.outed) { img.src = "./img/yc.png"; tds[index].style.backgroundColor = 'grey'; alert('别玩儿了!怎么可能中奖呢?'); console.log(img.outed); img.outed = true; } else { alert('这个已经被抽过了!'); } };}

文件目录结构:

72448ead600c1532561049c67acafac8.webp


浏览 32
点赞
评论
收藏
分享

手机扫一扫分享

分享
举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

分享
举报