我只需要通過使用CSS這樣收我的模式:http://jsfiddle.net/raving/1mhsynmw/關閉模態使用CSS只
但是,我無法得到它的工作。下面是我的模態。
function alert(msg) {
\t document.getElementById("alert").innerHTML = '<div class="modal-overlay"><div class="modal"><div class="modal-container"><h3>' + msg + '</h3><p>' + msg + '</p></div><p class="modal-footer"><a href="javascript:" id="ok">OK</a></p></div>';
}
alert("This is some text to show you this modal. This is some text to show you this modal. This is some text to show you this modal. This is some text to show you this modal.");
body {
font-family:arial;
font-size:11px;
}
.modal {
position: fixed;
top: 20px;
margin-left: auto;
margin-right: auto;
left: 0;
right: 0;
width: 200px;
box-shadow: 0 4px 6px 1px rgba(50, 50, 50, 0.14);
background: #fff;
}
.modal p {
\t cursor:default;
}
.modal-container {
\t padding: 10px;
}
.modal p a {
\t color:#555;
}
.modal-footer a {
\t display:block;
\t border:1px solid #eee;
\t width:9.5%;
\t padding:3px;
\t background:#fff;
\t text-decoration:none;
\t float:right;
}
.modal-footer {
background: #fafafa;
border-top: 1px solid #eee;
margin-bottom: 0px;
\t margin-top:0px;
\t padding:8px;
\t height:25px;
}
.modal h3 {
\t margin:0px;
\t white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 175px;
}
.modal-last {
\t padding-bottom:0px;
}
.modal-overlay:before {
content: '';
position: fixed;
top: 0px;
left: 0px;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.5);
}
<div id="alert"></div>
<h3>Content..</h3>
<p>Just to show it's a modal</p>
問:有沒有辦法關閉模式,而不使用Javascript?而這是不可能的,我怎樣才能使用JavaScript來關閉這種模式?
什麼使模態密切和在什麼時候? – colecmc
@colecmc模塊在點擊確定時應該關閉。 – Mia
你的所有樣式都不使用':target'僞選擇器,而你的模態沒有任何'id =「my_id」'屬性,它將被用在' Aprillion