前端使用html+js+css实现一个弹出选择框

前端使用html+js+css实现一个弹出选择框

弹出一个选择框,支持用户取消和确认
效果图:
在这里插入图片描述

index.html页面:

<div class="tip" id="tip">
  <p>这是一个简单的弹出窗</p>
  <button class="cancel" id="cancel">取消</button>
  <button class="ok" id="ok">确定</button>
</div>

index.js页面

let tip = document.getElementById("tip")
let ok = document.getElementById("ok")
let cancel = document.getElementById("cancel")
ok.onclick = () => {
  // 点击确认的操作,删除标签
  tip.remove()
}
cancel.onclick = () => {
  // 点击确认的操作,删除标签
  tip.remove()
}
``

index.css页面

.tip{
  width: 300px;
  height: 140px;
  background-color: #ffffff;
  border: 2px solid #ffffff;
  border-radius: 6px;
  padding: 15px 8px;
  text-align: center;
  display: inline-block;
  font-size: 15px;
  transition-duration: 0.4s;
  cursor: pointer;
  text-decoration: none;
  outline: none;
  font-weight: 600;
  background-color: #ffffff;
  color: #000000;
  box-shadow: 0px 10px 10px #a2a2a2;
  transition: all 1s;
}
.cancel{
  background-color: #0099CC;
  border-radius: 10px;
  border: 2px solid #ffffff;
  border-radius: 6px;
  padding: 5px 8px;
  text-align: center;
  display: inline-block;
  font-size: 15px;
  transition-duration: 0.4s;
  cursor: pointer;
  text-decoration: none;
  outline: none;
  font-weight: 400;
  box-shadow: 0px 5px 10px #e5e5e5;
  color: #ffffff;
  margin-top: 30px;
}
.ok{
  background-color: #cc1400;
  border-radius: 10px;
  border: 2px solid #ffffff;
  border-radius: 6px;
  padding: 5px 8px;
  text-align: center;
  display: inline-block;
  font-size: 15px;
  transition-duration: 0.4s;
  cursor: pointer;
  text-decoration: none;
  outline: none;
  font-weight: 400;
  box-shadow: 0px 5px 10px #e5e5e5;
  color: #ffffff;
  margin-top: 30px;
}
.cancel:hover {
  border: 2px solid #0099CC;
  background-color: #ffffff;
  color: #0099CC;
  font-weight: 700;
}
.ok:hover {
  border: 2px solid #cc1400;
  background-color: #ffffff;
  color: #cc1400;
  font-weight: 700;
}
.ok:active {
  background-color: #838383d8;
}
.cancel:active {
  background-color: #838383d8;
}
.ok:focus {
  outline: none;
}
.cancel:focus {
  outline: none;
}
  • 14
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值