Created
February 12, 2018 09:41
-
-
Save aaronsummers/3a714ff71eb59162cafde4faa238ea0b to your computer and use it in GitHub Desktop.
Simple Popup
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
<a class="btn" data-popup-open="popup-1" href="#">Open Popup #1</a> | |
<div class="popup" data-popup="popup-1"> | |
<div class="popup-inner"> | |
<h2>Wow! This is Awesome! (Popup #1)</h2> | |
<p>Donec in volutpat nisi. In quam lectus, aliquet rhoncus cursus a, congue et arcu. Vestibulum tincidunt neque id nisi pulvinar aliquam. Nulla luctus luctus ipsum at ultricies. Nullam nec velit dui. Nullam sem eros, pulvinar sed pellentesque ac, feugiat et turpis. Donec gravida ipsum cursus massa malesuada tincidunt. Nullam finibus nunc mauris, quis semper neque ultrices in. Ut ac risus eget eros imperdiet posuere nec eu lectus.</p> | |
<p><a data-popup-close="popup-1" href="#">Close</a></p> | |
<a class="popup-close" data-popup-close="popup-1" href="#">x</a> | |
</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
$(function() { | |
//----- OPEN | |
$('[data-popup-open]').on('click', function(e) { | |
var targeted_popup_class = jQuery(this).attr('data-popup-open'); | |
$('[data-popup="' + targeted_popup_class + '"]').fadeIn(350); | |
e.preventDefault(); | |
}); | |
//----- CLOSE | |
$('[data-popup-close]').on('click', function(e) { | |
var targeted_popup_class = jQuery(this).attr('data-popup-close'); | |
$('[data-popup="' + targeted_popup_class + '"]').fadeOut(350); | |
e.preventDefault(); | |
}); | |
}); |
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
//colors | |
$color_royal_purple_approx: rebeccapurple; | |
$black_75: rgba(0,0,0,0.75); | |
$black_100: rgba(0,0,0,1); | |
$white: #fff; | |
$black_80: rgba(0,0,0,0.8); | |
//fonts | |
$font_0: Arial; | |
$font_1: Sans-Serif; | |
.test { | |
color: $color_royal_purple_approx; | |
} | |
.popup { | |
width: 100%; | |
height: 100%; | |
display: none; | |
position: fixed; | |
top: 0; | |
left: 0; | |
background: $black_75; | |
} | |
.popup-inner { | |
max-width: 700px; | |
width: 90%; | |
padding: 40px; | |
position: absolute; | |
top: 50%; | |
left: 50%; | |
transform: translate(-50%, -50%); | |
box-shadow: 0 2px 6px $black_100; | |
border-radius: 3px; | |
background: $white; | |
} | |
.popup-close { | |
width: 30px; | |
height: 30px; | |
padding-top: 4px; | |
display: inline-block; | |
position: absolute; | |
top: 0; | |
right: 0; | |
transition: ease 0.25s all; | |
transform: translate(50%, -50%); | |
border-radius: 1000px; | |
background: $black_80; | |
font-family: $font_0, $font_1; | |
font-size: 20px; | |
text-align: center; | |
line-height: 100%; | |
color: $white; | |
&:hover { | |
transform: translate(50%, -50%) rotate(180deg); | |
background: $black_100; | |
text-decoration: none; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment