content logo

React Popups:

React Popup with Fade-in Effect and Gradient Background

Websites that are gradient usually have a special appeal to the user. In this post, you can have a pop-up with a gradient button. This gradient button has a green border. Clicking on this button will open a pop-up with a white background and a green title. This pop-up contains text. You can close the pop-up by clicking on the pop-up icon.

#

Gradient Popup Code

#

React Popup Code

#

CSS Popup Fade Effect

#

Glassy Popup Button Code

<!-- This script got from frontendfreecode.com -->
<div id="root"></div><a style="font-size: 8pt; text-decoration: none" target="_blank" href="http://frontendfreecode.com">Free Frontend</a>
                                                                            
*,
*:before,
*:after {
  box-sizing: border-box;
}

html, body {
  padding: 0;
  margin: 0;
  width: 100%;
  height: 100%;
}
body {
  text-align: center;
  background-image: linear-gradient(120deg, #a6c0fe 0%, #f68084 100%);
  background-size: cover;
  background-repeat: no-repeat;
    
}
h1,h2,a,p {
  font-family: helvetica, sans-serif;
}
h1 {
  font-size: 3em;
  text-align: center;
  color: #00898E;
  margin: 0;
  padding: 30vh 0 1em;
}
h2 {
  text-align: center;
  white-space: nowrap;
  color: #00898E;
}
a {
  text-decoration: none;
  color: #fff;
}
p {
  text-align: left;
}
.btn {
  display: inline-block;
  padding: 10px 20px;
  border: 2px solid #00898E;
  border-radius: 10px;
  transition: background .3s;
}
.btn:hover {
  background: #00898E;
}
.popup {
  position: fixed;
  padding: 10px;
  max-width: 500px;
  border-radius: 10px;
  top: 50%;
  left: 50%;
  /*transform: translate(-50%,-50%);*/
  background: rgba(255,255,255,.9);
  visibility: hidden;
  opacity: 0;
  -webkit-transition: opacity .5s, visibility 0s linear .5s;
  transition: opacity .5s, visibility 0s linear .5s;
  z-index: 1;
}
.popup:target {
  visibility: visible;
  opacity: 1;
  -webkit-transition-delay: 0s;
  transition-delay: 0s;
}
.popup-close {
  position: absolute;
  padding: 10px;
  max-width: 500px;
  border-radius: 10px;
  top: 50%;
  left: 50%;
  transform: translate(-50%,-50%);
  background: rgba(255,255,255,.9);
}
.popup .close {
  position: absolute;
  right: 5px;
  top: 5px;
  padding: 5px;
  color: #000;
  transition: color .3s;
  font-size: 2em;
  line-height: .6em;
  font-weight: bold;
}
.popup .close:hover {
  color: #00E5EE;
}

.close-popup {
  background: rgba(0,0,0,.7);
  cursor: default;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  opacity: 0;
  visibility: hidden;
  -webkit-transition: opacity .5s, visibility 0s linear .5s;
  transition: opacity .5s, visibility 0s linear .5s;
}
.popup:target + .close-popup{  
  opacity: 1;
  visibility: visible;
  -webkit-transition-delay: 0s;
  transition-delay: 0s;
}
function App() {
  return /*#__PURE__*/(
    React.createElement("div", null, /*#__PURE__*/
    React.createElement("h1", null, "Popup Please"), /*#__PURE__*/
    React.createElement("a", { href: "#popup1", class: "btn" }, "Reveal Popup"), /*#__PURE__*/
    React.createElement("div", { id: "popup1", class: "popup" }, /*#__PURE__*/
    React.createElement("a", { href: "#", class: "close" }, "\xD7"), /*#__PURE__*/
    React.createElement("h2", null, "The Popup Has Arrived"), /*#__PURE__*/
    React.createElement("p", null, "This popup can be closed by clicking the fancy ", /*#__PURE__*/React.createElement("b", null, "\xD7"), " in the top right corner or by clicking outside the popup box!")), /*#__PURE__*/
    React.createElement("a", { href: "#", class: "close-popup" })));
}
ReactDOM.render( /*#__PURE__*/
React.createElement(App, null),
document.getElementById('root'));
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css">
<script src='https://cdnjs.cloudflare.com/ajax/libs/react/16.13.1/umd/react.production.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.13.1/umd/react-dom.production.min.js'></script>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- This script got from frontendfreecode.com -->

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css">
<script src='https://cdnjs.cloudflare.com/ajax/libs/react/16.13.1/umd/react.production.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.13.1/umd/react-dom.production.min.js'></script>
<style>
*,
*:before,
*:after {
  box-sizing: border-box;
}

html, body {
  padding: 0;
  margin: 0;
  width: 100%;
  height: 100%;
}
body {
  text-align: center;
  background-image: linear-gradient(120deg, #a6c0fe 0%, #f68084 100%);
  background-size: cover;
  background-repeat: no-repeat;
    
}
h1,h2,a,p {
  font-family: helvetica, sans-serif;
}
h1 {
  font-size: 3em;
  text-align: center;
  color: #00898E;
  margin: 0;
  padding: 30vh 0 1em;
}
h2 {
  text-align: center;
  white-space: nowrap;
  color: #00898E;
}
a {
  text-decoration: none;
  color: #fff;
}
p {
  text-align: left;
}
.btn {
  display: inline-block;
  padding: 10px 20px;
  border: 2px solid #00898E;
  border-radius: 10px;
  transition: background .3s;
}
.btn:hover {
  background: #00898E;
}
.popup {
  position: fixed;
  padding: 10px;
  max-width: 500px;
  border-radius: 10px;
  top: 50%;
  left: 50%;
  /*transform: translate(-50%,-50%);*/
  background: rgba(255,255,255,.9);
  visibility: hidden;
  opacity: 0;
  -webkit-transition: opacity .5s, visibility 0s linear .5s;
  transition: opacity .5s, visibility 0s linear .5s;
  z-index: 1;
}
.popup:target {
  visibility: visible;
  opacity: 1;
  -webkit-transition-delay: 0s;
  transition-delay: 0s;
}
.popup-close {
  position: absolute;
  padding: 10px;
  max-width: 500px;
  border-radius: 10px;
  top: 50%;
  left: 50%;
  transform: translate(-50%,-50%);
  background: rgba(255,255,255,.9);
}
.popup .close {
  position: absolute;
  right: 5px;
  top: 5px;
  padding: 5px;
  color: #000;
  transition: color .3s;
  font-size: 2em;
  line-height: .6em;
  font-weight: bold;
}
.popup .close:hover {
  color: #00E5EE;
}

.close-popup {
  background: rgba(0,0,0,.7);
  cursor: default;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  opacity: 0;
  visibility: hidden;
  -webkit-transition: opacity .5s, visibility 0s linear .5s;
  transition: opacity .5s, visibility 0s linear .5s;
}
.popup:target + .close-popup{  
  opacity: 1;
  visibility: visible;
  -webkit-transition-delay: 0s;
  transition-delay: 0s;
}
</style>

</head>
<body>
<div id="root"></div><div id="bcl"><a style="font-size:8pt;text-decoration:none;" href="http://www.devanswer.com">Free Frontend</a></div>
<script>
function App() {
  return /*#__PURE__*/(
    React.createElement("div", null, /*#__PURE__*/
    React.createElement("h1", null, "Popup Please"), /*#__PURE__*/
    React.createElement("a", { href: "#popup1", class: "btn" }, "Reveal Popup"), /*#__PURE__*/
    React.createElement("div", { id: "popup1", class: "popup" }, /*#__PURE__*/
    React.createElement("a", { href: "#", class: "close" }, "\xD7"), /*#__PURE__*/
    React.createElement("h2", null, "The Popup Has Arrived"), /*#__PURE__*/
    React.createElement("p", null, "This popup can be closed by clicking the fancy ", /*#__PURE__*/React.createElement("b", null, "\xD7"), " in the top right corner or by clicking outside the popup box!")), /*#__PURE__*/
    React.createElement("a", { href: "#", class: "close-popup" })));
}
ReactDOM.render( /*#__PURE__*/
React.createElement(App, null),
document.getElementById('root'));

</script>

</body>
</html>
Preview