I'm trying to use an open-source popout on my website. I would like to add a simple fade-in/fade-out effect, and also allow the popout to be closed when clicked outside the box. Below is the javascript:
/*
* SimpleModal Basic Modal Dialog
* http://simplemodal.com
*
* Copyright (c) 2013 Eric Martin - http://ericmmartin.com
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/mit-license.php
*/
jQuery(function ($) {
// Load dialog on page load
//$('#basic-modal-content').modal();
// Load dialog on click
$('#basic-modal .basic').click(function (e) {
$('#basic-modal-content').modal();
return false;
});
});
There is an answer on another post Close a div by clicking outside that provides a short javascript solution. I attempted to modify this code to fit mine, but I was not sure how to properly call the div's from the css.
Below is the CSS:
/*
* SimpleModal Basic Modal Dialog
* http://simplemodal.com
*
* Copyright (c) 2013 Eric Martin - http://ericmmartin.com
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/mit-license.php
*/
#basic-modal-content {
display: none;
}
/* Overlay */
#simplemodal-overlay {
background-color: #000;
}
/* Container */
#simplemodal-container {
height: 360px;
width: 600px;
color: #bbb;
background-color: #333;
border: 4px solid #444;
padding: 12px;
}
#simplemodal-container .simplemodal-data {
padding: 8px;
}
#simplemodal-container code {
background: #141414;
border-left: 3px solid #65B43D;
color: #bbb;
display: block;
font-size: 12px;
margin-bottom: 12px;
padding: 4px 6px 6px;
}
#simplemodal-container a {
color: #ddd;
}
#simplemodal-container a.modalCloseImg {
background: url(../img/basic/x.png) no-repeat;
width: 25px;
height: 29px;
display: inline;
z-index: 3200;
position: absolute;
top: -15px;
right: -16px;
cursor: pointer;
}
#simplemodal-container h3 {
color: #84b8d9;
}
The button I am using is listed below : CSS/HTML
.button {
display: inline-block;
padding: 10px 20px;
margin: 10px 0;
position: center;
color: #ecf0f1;
}
/* BUTTON 8 */
#button-8 {
background-color: #34495e;
overflow: hidden;
-webkit-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
}
#button-8:hover {
-webkit-box-shadow: 0px 0px 15px #34495e;
box-shadow: 0px 0px 15px #34495e;
}
And the HTML (clicking on button to open Modal)
<a href='#' class='basic'>
<div class="button" id="button-8">Click Me</div>
</a>