首先做出来的效果图是这样的
代码如下
<div class="hua_zd m_15" id="toupiao">
<div class="hua_zd_00_z" onclick="zd_change(0)">涨</div>
<div class="hua_zd_00_d m_20" onclick="zd_change(1)">跌</div>
<button class="hua_zd_btn m_20 let_space_1">查看整体投票结果</button>
</div>
点击第一次弹窗为投票成功
代码
<div id="windows" class="windows">
<div class="windows_content">
<div class="tanchuang_one">温馨提示</div>
<div class="tanchuang_two">投票成功!</div>
<div class="tanchunag_four"></div>
<div class="tanchuang_three" onclick="toupiao_none()">确定</div>
</div>
</div>
弹窗和投票的css
.hua_zd{
background: #f8f8f8;
padding: 18.5px 7.5px;
}
.hua_zd_title{
color: #3a3a3a;
font-size: 17px;
font-weight: bold;
}
.hua_zd_00_z{
background: #ffffff;
padding:5px 7.5px;
font-size: 16.5px;
color: #3a3a3a;
font-weight: bold;
line-height: 30px;
border-radius: 3.75px;
border: none;
}
.hua_zd_00_d{
background: #ffffff;
padding:5px 7.5px;
font-size: 16.5px;
color: #3a3a3a;
font-weight: bold;
line-height: 30px;
border-radius: 3.75px;
border: none;
}
.hua_active_z{
background: #00ae66;
color: #ffffff;
text-align: center;
}
.hua_active_d{
background: #00ae66;
color: #ffffff;
text-align: center;
}
.hua_active_01 {
user-select: none;
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
}
.hua_zd_btn{
width: 100%;
height: 45px;
display: flex;
justify-content: center;
align-items: center;
color: #ffffff;
font-size: 16px;
background: #00ae66;
border-radius: 40px;
border: none;
}
.windows_content{
width: 290px;
height: 170px;
border-radius: 5px;
margin: 70% auto;
z-index: 30; /*置顶窗口层*/
background-color: white;
}
.tanchuang_one {
font-size: 25px;
position: relative;
top: 25px;
}
.tanchuang_two {
color: #999999;
position: relative;
left: 35px;
width: 230px;
top: 40px;
}
.tanchuang_three {
font-size: 18px;
color: #5286ff;
position: relative;
top: 12px;
}
.tanchunag_four {
border: solid 1px transparent;
border-bottom-color: #E4E7ED;
margin-top: 70px
}
.windows{
position: fixed;
top: 0;
right: 0;
left: 0;
bottom: 0;
display: none;
background-color: rgba(0, 0, 0, 0.2);
z-index: 20; /*背景层*/
text-align: center;
}
然后再次点击就会出现您已投票成功,请勿再次投票
js代码如下
<script>
function zd_change(index) {
if ($('.hua_zd_00_z').css("color") === "rgb(58, 58, 58)" && $('.hua_zd_00_d').css("color") === "rgb(58, 58, 58)") {
if (index == "0") {
$(".hua_zd_00_z").addClass("hua_active_z");
}
if (index == "1") {
$(".hua_zd_00_d").addClass("hua_active_d");
}
$('.windows').css('display','block')
}else {
$('.windows').css('display','block')
$('.tanchuang_two').html("您已投票请勿重复操作!")
}
}
function toupiao_none() {
$('.windows').css('display','none')
}
</script>
以上就是代码全部过程,记得要添加js的包,在我的博客中有发过,希望可以帮到大家,也希望大家能写出越来越厉害的代码,可以在程序路上越走越远。
标签:none,相等,hua,color,js,zd,投票,font,border From: https://blog.51cto.com/u_16281588/8401076