2016-07-24 7 views
1

を含まは、私はそうのようなHTMLを持つ要素

1)その内容をぼかし。例えば、フォームが(AJAX経由で)いくつかのデフォルト値をロードしている間に、私は含まれたものを "ぼやけ"にしたい(私は#containerの不透明度だと思う)。しかし、人々がフィールドをクリックできるようにしたくない。

2)呼び出しが失敗した場合、それをクリックすると、効果的)(データのリロードを試みるクリックため

をお待ちしておりますことを意味する」と事実上不可能にこれをやっている、「モーダル」何かに#coverを回し"div?私はフィールドをクリックするとイベントがフィールド自体にあり、それがコンテナにバブルアップすることを認識しています...間違った方向になっていますか?

+0

:ここ

はコードです。 'css'、' javascript'をQuestionに入れてもいいですか? – guest271314

+0

実際には非常に複雑なポリマー要素です...これは単純化されたバージョンです! – Merc

答えて

0

私はあなたがしたいことについてはあまりよく分かりませんが、私はあなたのためにこれを作っています。ボタンをクリックしてモーダルを開くと、ボックスが表示され、その他のコンテンツがbluredになります。どちらの要件は可能なはず

// Get the modal 
 
var modal = document.getElementById('myModal'); 
 

 
// Get the button that opens the modal 
 
var btn = document.getElementById("myBtn"); 
 

 
// Get the <span> element that closes the modal 
 
var span = document.getElementsByClassName("close")[0]; 
 

 
// When the user clicks the button, open the modal 
 
btn.onclick = function() { 
 
    modal.style.display = "block"; 
 
document.getElementById("blurit").style.filter = "blur(4px)"; 
 
    document.getElementById("blurit").style.WebkitFilter = "blur(4px)"; 
 
} 
 

 
// When the user clicks on <span> (x), close the modal 
 
span.onclick = function() { 
 
    modal.style.display = "none"; 
 
document.getElementById("blurit").style.filter = "blur(0)"; 
 
    document.getElementById("blurit").style.WebkitFilter = "blur(0)"; 
 
} 
 

 
// When the user clicks anywhere outside of the modal, close it 
 
window.onclick = function(event) { 
 
    if (event.target == modal) { 
 
     modal.style.display = "none"; 
 
document.getElementById("blurit").style.filter = "blur(0)"; 
 
    document.getElementById("blurit").style.WebkitFilter = "blur(0)"; 
 
    } 
 
}
/* The Modal (background) */ 
 
.modal { 
 
    display: none; /* Hidden by default */ 
 
    position: fixed; /* Stay in place */ 
 
    z-index: 1; /* Sit on top */ 
 
    padding-top: 100px; /* Location of the box */ 
 
    left: 0; 
 
    top: 0; 
 
    width: 100%; /* Full width */ 
 
    height: 100%; /* Full height */ 
 
    overflow: auto; /* Enable scroll if needed */ 
 
    background-color: rgb(0,0,0); /* Fallback color */ 
 
    background-color: rgba(0,0,0,0.4); /* Black w/ opacity */ 
 
} 
 

 
/* Modal Content */ 
 
.modal-content { 
 
    background-color: #fefefe; 
 
    margin: auto; 
 
    padding: 20px; 
 
    border: 1px solid #888; 
 
    width: 80%; 
 
} 
 

 
/* The Close Button */ 
 
.close { 
 
    color: #aaaaaa; 
 
    float: right; 
 
    font-size: 28px; 
 
    font-weight: bold; 
 
} 
 

 
.close:hover, 
 
.close:focus { 
 
    color: #000; 
 
    text-decoration: none; 
 
    cursor: pointer; 
 
}
<div id="blurit"> 
 
<p>Test it</p> 
 
<img src="https://static.pexels.com/photos/909/flowers-garden-colorful-colourful.jpg" alt="Pineapple" width="500" height="300"><br><br> 
 
<button onclick="myFunction()" id="myBtn">Try it</button> 
 
</div> 
 
<div id="myModal" class="modal"> 
 

 
    <!-- Modal content --> 
 
    <div class="modal-content"> 
 
    <span class="close">×</span> 
 
    <p>Some text in the Modal..</p> 
 
    </div> 
 

 
</div>

関連する問題