logo DevAnswer - Developers Answer

Bootstrap Popup Close on Page Scroll

25th September

Preview


Source Code
                            <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- This script got from www.devanswer.com -->


<style>
* {
  margin: 0;
  font-family: 'Source Sans Pro', sans-serif;
}
a {
  text-decoration: none;
}
header {
  background: url(http://www.devanswer.com/img/pulley.jpg);
  background-size: cover;
  background-position: center;
  height: 100vh!important;
  width: 100%;
}
#darkBack {
  width: 100%;
  height: 100vh!important;
  background: rgba(76, 56, 75, .15);
}
#popUp {
  position: fixed;
  max-width: 350px;
  height: 225px;
  background: rgba(236, 240, 241, 1);
  border: 7px solid #fff;
  bottom: 0;
  margin-left: 0;
  -webkit-transition: all 1s ease;
  -moz-transition: all 1s ease;
  -o-transition: all 1s ease;
  transition: all 1s ease;
}
#new span {
  background: #fff;
  position: absolute;
  color: #1c8dc4;
  padding: 4px 10px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 1px;
  margin-top: -5px;
}
#popUp .close {
  color: #464646;
  right: 8px;
  top: 0px;
  position: absolute;
  font-size: 20px;
  cursor: pointer;
}
#popUp h2 {
  font-size: 17px;
  color: #464646;
  line-height: 24px;
  font-weight: 400;
  text-align: center;
  margin-top: 40px;
  padding: 0 20px;
}
#body {
  height: 1200px;
  background: #eee;
}
a.button {
  margin: 0 auto;
  text-align: center;
  right: 0;
  left: 0;
  position: absolute;
  width: 120px;
  font-size: 15px;
  color: #fff;
  border-bottom: 2px solid #18729f;
  background: #1c8dc4;
  border-radius: 4px;
  padding: 8px 0;
}
#plus {
  position: fixed;
  color: #fff;
  bottom: 15%;
  font-size: 15px;
  margin-left: -425px;
  -webkit-transition: all 1.25s ease;
  -moz-transition: all 1.25s ease;
  -o-transition: all 1.25s ease;
  transition: all 1.25s ease;
  cursor: pointer;
  text-align: left;
  letter-spacing: 1px;
}
#plus span {
  position: absolute;
  margin-top: 38px;
  left: 4px;
}
#plus::after {
  content: '';
  display: block;
  display: relative;
  border-top: 55px solid transparent;
  border-bottom: 55px solid transparent;
  border-left: 55px solid #1c8dc4;
}
@media all and (max-width: 900px) {
  #popUp {
    margin-left: -425px;
  }
  #plus {
    margin-left: 0px;
  }
}
</style>

</head>
<body>
<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<header>
  <div id="darkBack"></div>
  <div id="popUp">
    <div id="close" class="close"><i class="fa fa-times"></i></div>
    <div id="new"><span>NEW!</span></div>
    <h2>I'm a notification popup that isn't too distracting or in your face. Scroll down or close me and I will go away. You'll still be able to open me later on don't worry.</h2>
    <br>
    <a href="#" target="_blank" class="button">Visit Page</a>
  </div>
  <div id="plus"><span>NEW<br>&nbsp;&nbsp;<i class="fa fa-plus"></i></span></div>
</header>
<div id="body"></div><div id="bcl"><a style="font-size:8pt;text-decoration:none;" href="http://www.devanswer.com">Developers Answer</a></div>
<script>
$(document).scroll(function() {
  var scroll = $(this).scrollTop();
  if (scroll >= 150) {
    $("#popUp").css("margin-left", "-425px");
    $("#plus").css("margin-left", "0px");
  }
});
$("#plus").click(function() {
  $("#popUp").css("margin-left", "0px");
  $("#plus").css("margin-left", "-425px");
});
$("#close").click(function() {
  $("#popUp").css("margin-left", "-425px");
  $("#plus").css("margin-left", "0px");
});
</script>

</body>
</html>                        



Other Codes