为了账号安全,请及时绑定邮箱和手机立即绑定

如何制作多个文本叠加层

如何制作多个文本叠加层

慕田峪4524236 2019-04-18 13:15:12
我有以下问题:我试图制作倍数叠加,它只是不起作用。它始终只显示最后一个作为叠加层。即使当我按下第一个按钮或第二个按钮时我输入不同的“id” - 我将覆盖2,当我按下id“overlay1”时我永远不会看到overlay1我怎样才能使它工作?function on() {  document.getElementById("overlay1").style.display = "block";}function off() {  document.getElementById("overlay1").style.display = "none";}function on() {  document.getElementById("overlay2").style.display = "block";}function off() {  document.getElementById("overlay2").style.display = "none";}#overlay1 {  position: fixed;  display: none;  width: 100%;  height: 100%;  top: 0;  left: 0;  right: 0;  bottom: 0;  background-color: rgba(0, 0, 0, 0.5);  z-index: 2;  cursor: pointer;}#text1 {  position: absolute;  top: 50%;  left: 50%;  font-size: 50px;  color: white;  transform: translate(-50%, -50%);  -ms-transform: translate(-50%, -50%);}#overlay2 {  position: fixed;  display: none;  width: 100%;  height: 100%;  top: 0;  left: 0;  right: 0;  bottom: 0;  background-color: rgba(0, 0, 0, 0.5);  z-index: 2;  cursor: pointer;}#text2 {  position: absolute;  top: 50%;  left: 50%;  font-size: 50px;  color: white;  transform: translate(-50%, -50%);  -ms-transform: translate(-50%, -50%);}<div id="overlay1" onclick="off()">  <div id="text1">Overlayy878 Text</div></div><div style="padding:20px">  <h2>Overlay with Text</h2>  <button onclick="on()">Turn on overlay effect</button></div><div id="overlay2" onclick="off()">  <div id="text2">Overlay 2 TWO Text</div></div><div style="padding:20px">  <h2>Overlay with Text</h2>  <button onclick="on()">Turn on overlay effect</button></div>
查看完整描述

2 回答

  • 2 回答
  • 0 关注
  • 372 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号