我很擅長html和css,但在Javascript中很糟糕。圍繞浮動div的昏暗區域
這是HTML編碼我:
<script>
var toggle = function() {
var mydiv = document.getElementById('nodate');
if (mydiv.style.display === 'block' || mydiv.style.display === '')
mydiv.style.display = 'none';
else
mydiv.style.display = 'block'
}
</script>
<div id="nodate" style="display:none"><span class="A"> <input type="image" src="http://www.weebly.com/uploads/1/6/7/6/16768236/custom_themes/307429121386408805/files/close-icon.png?1384992227202" width="42" onclick="toggle();" /></span><b>There are no reservations listed under the date you selected. </b>Please select another date or ask for assistance.<br><br><image src=」http://www.weebly.com/uploads/1/6/7/6/16768236/custom_themes/307429121386408805/files/sorry.jpg?1384992565622」 width=」200」/></div>
這個CSS代碼隨之而來:
#nodate {
background-color: #fff;
width: 95%;
height-min: 300px;
z-index: 500;
border: 2px solid #000;
padding: 10px;
margin-left: auto;
margin-right: auto;
position:absolute;
top: -10px;
left:0;
right:0;
margin-left:auto;
margin-right:auto;
}
.A {
float: right;
margin-top: -30px;
margin-right: -30px;
}
當DIV推出,它涵蓋的部分的頁面,但我希望它可以調暗它周圍的區域。什麼是最簡單的方法,我該怎麼做(如果使用Javascript,請幫我解決)
要變暗頁面的其餘部分嗎 –
創建一個覆蓋所有內容的div,然後在其上放置一些東西。 –
你是否在尋找一種模態類型的視圖? –