//css
.duihuan{
display: flex;
justify-content:space-between;
padding: 10px;
border-bottom: 1px solid #ddd;
}
.coupon_list{
padding: 10px;
border-bottom: 2px solid yellow;
}
.coupon_list dl{
display: inline-block;
width: 49%;
text-align: center;
color:red;
}
.coupon_list dl dt img{
width: 100%;
}
//html
<div class="coupon_list" id="coupon_list">
<dl>
<dt><img src="../images/money5.png"></dt>
<dd>需消耗:500积分</dd>
</dl>
<dl>
<dt><img src="../images/money10.png"></dt>
<dd>需消耗:1000积分</dd>
</dl>
<dl>
<dt><img src="../images/money20.png"></dt>
<dd>需消耗:2000积分</dd>
</dl>
<dl>
<dt><img src="../images/money50.png"></dt>
<dd>需消耗:5000积分</dd>
</dl>
</div>
//js
<script type="text/javascript">
var list=document.querySelector(".coupon_list");var dl=list.getElementsByTagName("dl")
var len=dl.length;
for(var i=0;i<len; i++){ //循环出来
dl[i].onclick=function(){
alert(2)
}
}
//alert(this.className);弹出类名
本文展示了一个简单的积分兑换优惠券的网页示例,通过HTML、CSS和JavaScript实现了优惠券列表及点击效果。用户可以直观地看到不同额度优惠券所需的积分。
895

被折叠的 条评论
为什么被折叠?



