Created
September 4, 2015 18:13
-
-
Save joaomosantos/ae34bf9a19dd315b6494 to your computer and use it in GitHub Desktop.
Javascript Modal v.1.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* { margin: 0; padding: 0; } | |
.content-modal { | |
width: 800px; | |
height: 400px; | |
background: #fff; | |
margin-left: -400px; | |
margin-top: -200px; | |
position: absolute; | |
left: 50%; | |
top: 50%; | |
} | |
.bg-modal { | |
position: fixed; | |
opacity: 0.9; | |
width: 100%; | |
height: 100%; | |
background: #000; | |
display: none; | |
} | |
.content-modal { | |
display: none; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="container"> | |
<div class="bg-modal"></div> | |
<a href="javascript:void(0);" class="btn-modal" rel="teste01.html">Modal 01</a> | |
<a href="javascript:void(0);" class="btn-modal" rel="teste02.html">Modal 02</a> | |
<a href="javascript:void(0);" class="btn-modal" rel="teste03.html">Modal 03</a> | |
<div class="content-modal"> | |
<a href="javascript:void(0);" class="btn-fechar">Fechar</a> | |
<div class="inner-modal"></div> | |
</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
var relLogos; | |
$(".btn-modal").click(function(event) { | |
event.preventDefault(); | |
$(".bg-modal").fadeIn("slow"); | |
$(".content-modal").show(400); | |
relLogos = $(this).attr("rel"); | |
$(".inner-modal").load(relLogos); | |
}); | |
$(".btn-fechar").click(function() { | |
$(".content-modal").hide(200); | |
$(".bg-modal").fadeOut("slow"); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment