我有以下問題:我試圖制作倍數(shù)疊加,它只是不起作用。它始終只顯示最后一個作為疊加層。即使當我按下第一個按鈕或第二個按鈕時我輸入不同的“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>
如何制作多個文本疊加層
慕田峪4524236
2019-04-18 13:15:12