HTML button on click show overlay layer - html

I am trying to show an overlay for full page when button on click. I intended to add an iframe in the content div for pop up. Here is my HTML:
And CSS to show and hide the overlay:
.box {
width: 20%;
margin: 0 auto;
background: rgba(255,255,255,0.2);
padding: 35px;
border: 2px solid #fff;
border-radius: 20px/50px;
background-clip: padding-box;
text-align: center;
}
.button {
font-size: 1em;
padding: 10px;
color: #fff;
border: 2px solid blue;
border-radius: 20px/50px;
text-decoration: none;
cursor: pointer;
transition: all 0.3s ease-out;
}
.button:hover {
background: blue;
}
.overlay {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: rgba(0, 0, 0, 0.7);
transition: opacity 500ms;
visibility: hidden;
opacity: 0;
}
.overlay:target {
visibility: visible;
opacity: 1;
}
.popup {
margin: 70px auto;
padding: 20px;
background: #fff;
border-radius: 5px;
width: 30%;
position: relative;
transition: all 5s ease-in-out;
}
.popup h2 {
margin-top: 0;
color: #333;
font-family: Tahoma, Arial, sans-serif;
}
.popup .close {
position: absolute;
top: 20px;
right: 30px;
transition: all 200ms;
font-size: 30px;
font-weight: bold;
text-decoration: none;
color: #333;
}
.popup .close:hover {
color: orange;
}
.popup .content {
max-height: 30%;
overflow: auto;
}
<div style="height: 1200px;">
<div class="box">
<a class="button" href="#popup1">Show Overlay</a>
</div>
<div id="popup1" class="overlay">
<div class="popup">
<h2>Title</h2>
<a class="close" href="#">×</a>
<div class="content">
Content
</div>
</div>
</div>
</div>
My jsfiddle
However, there is a slight issue with the styling. The overlay does not cover the part below when scrolling down. It only covers the part before start scrolling down. I tried to set the height to 100% but to no futile.
Any ideas how to fix this?
Thanks!

Use position: fixed; instead of position: absolute;. position absolute set an auto height based on window height not body.
.box {
width: 20%;
margin: 0 auto;
background: rgba(255, 255, 255, 0.2);
padding: 35px;
border: 2px solid #fff;
border-radius: 20px/50px;
background-clip: padding-box;
text-align: center;
}
.button {
font-size: 1em;
padding: 10px;
color: #fff;
border: 2px solid blue;
border-radius: 20px/50px;
text-decoration: none;
cursor: pointer;
transition: all 0.3s ease-out;
}
.button:hover {
background: blue;
}
.overlay {
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: rgba(0, 0, 0, 0.7);
transition: opacity 500ms;
visibility: hidden;
opacity: 0;
}
.overlay:target {
visibility: visible;
opacity: 1;
}
.popup {
margin: 70px auto;
padding: 20px;
background: #fff;
border-radius: 5px;
width: 30%;
position: relative;
transition: all 5s ease-in-out;
}
.popup h2 {
margin-top: 0;
color: #333;
font-family: Tahoma, Arial, sans-serif;
}
.popup .close {
position: absolute;
top: 20px;
right: 30px;
transition: all 200ms;
font-size: 30px;
font-weight: bold;
text-decoration: none;
color: #333;
}
.popup .close:hover {
color: orange;
}
.popup .content {
max-height: 30%;
overflow: auto;
}
<div style="height: 1200px;">
<div class="box">
<a class="button" href="#popup1">Show Overlay</a>
</div>
<div id="popup1" class="overlay">
<div class="popup">
<h2>Title</h2>
<a class="close" href="#">×</a>
<div class="content">
Content
</div>
</div>
</div>
</div>

Related

Button Size cant be Resize

So , i want to make the button wider , not auto size to the text , i want it like 300px , i just try to add width on every class , but nothing seems working , is it because the button box line from text border ? i think its because the button from text border , so its auto resize with the text , am i right about it ? if that was the problem, can i click on a col-md-6 div for example ?
body {
font-family: Arial, sans-serif;
background: url(http://www.shukatsu-note.com/wp-content/uploads/2014/12/computer-564136_1280.jpg) no-repeat;
background-size: cover;
height: 100vh;
}
h1 {
text-align: center;
font-family: Tahoma, Arial, sans-serif;
color: #06D85F;
margin: 80px 0;
}
.box {
width: 40%;
margin: 0 auto;
background: rgba(255,255,255,0.2);
padding: 35px;
border: 2px solid #fff;
border-radius: 20px/50px;
background-clip: padding-box;
text-align: center;
}
.button {
font-size: 1em;
padding: 10px;
color: #fff;
border: 2px solid #06D85F;
border-radius: 20px/50px;
text-decoration: none;
cursor: pointer;
transition: all 0.3s ease-out;
}
.button:hover {
background: #06D85F;
}
.overlay {
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: rgba(0, 0, 0, 0.7);
transition: opacity 500ms;
visibility: hidden;
opacity: 0;
}
.overlay:target {
visibility: visible;
opacity: 1;
}
.popup {
margin: 70px auto;
padding: 20px;
background: #fff;
border-radius: 5px;
width: 30%;
position: relative;
transition: all 5s ease-in-out;
}
.popup h2 {
margin-top: 0;
color: #333;
font-family: Tahoma, Arial, sans-serif;
}
.popup .close {
position: absolute;
top: 20px;
right: 30px;
transition: all 200ms;
font-size: 30px;
font-weight: bold;
text-decoration: none;
color: #333;
}
.popup .close:hover {
color: #06D85F;
}
.popup .content {
max-height: 30%;
overflow: auto;
}
#media screen and (max-width: 700px){
.box{
width: 70%;
}
.popup{
width: 70%;
}
}
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<title>CodePen - Pure css popup box</title>
<link rel="stylesheet" href="./style.css">
</head>
<body>
<!-- partial:index.partial.html -->
<h1>Popup/Modal Windows without JavaScript</h1>
<a class="button" href="#popup1">Let me Pop up</a>
<div id="popup1" class="overlay">
<div class="popup">
<h2>Here i am</h2>
<a class="close" href="#">×</a>
<div class="content">
Thank to pop me out of that button, but now i'm done so you can close this window.
</div>
</div>
</div>
<!-- partial -->
</body>
</html>
EDITED Can i add href on col-md-6 class ?
SOLVED add display:inline-block;
a-tag is an inline element so your height and width set are ignored. Add display: inline-block; and width: 300px; in the class button.
.button {
font-size: 1em;
padding: 10px;
color: #fff;
border: 2px solid #06D85F;
border-radius: 20px/50px;
text-decoration: none;
cursor: pointer;
transition: all 0.3s ease-out;
display: inline-block;
width: 300px;
}
you do not need to add col-md-6 unless you want to use such space. Just add width property in the button class or in the custom class as per your need.
.button {
width: 300px;
font-size: 1em;
padding: 10px;
color: #fff;
border: 2px solid #06D85F;
border-radius: 20px/50px;
text-decoration: none;
cursor: pointer;
transition: all 0.3s ease-out;
display:block;
}

CSS position is not working properly on hover

I try to position div on another div.
when i hover on .lg-each-contest the .current-caption will appear.
when hover on .time the .current-caption hover will be same.
Here is my code
.lg-current-inner {
border: 1px solid #bdbdbd;
margin-bottom: 30px;
position: relative;
}
.lg-each-contest:hover .current-caption {
opacity: 1;
}
.lg-current-banner .amount {
position: absolute;
top: 5px;
background-color: #fea700;
padding: 5px 12px;
font-size: 22px;
right: 0;
font-weight: 600;
color: #fff;
}
.lg-current-content {
padding: 10px;
}
.lg-current-content h3 {
font-size: 24px;
line-height: 36px;
margin-top: 10px;
}
.time {
border-top: 1px solid #bdbdbd;
position: relative;
}
.time .remaning-time {
padding: 10px;
}
.time .remaning-time .each-time {
font-size: 14px;
font-weight: 500;
}
.time .remaning-time .submissions {
padding: 2px 10px;
background: #1bcd80;
font-weight: 500;
color: #fff;
border-radius: 2px;
}
.current-caption {
position: absolute;
top: 0;
left: 0;
cursor: pointer;
right: 0;
bottom: 0;
padding: 25% 0;
width: 100%;
height: 100%;
background-color: rgba(63, 97, 132, 0.5);
text-align: center;
font-size: 15px;
opacity: 0;
-webkit-transition: all 0.4s ease-out;
-moz-transition: all 0.4s ease-out;
-o-transition: all 0.4s ease-out;
-ms-transition: all 0.4s ease-out;
transition: all 0.4s ease-out;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.current-caption button {
color: #fea700;
padding: 6px 20px;
opacity: 1;
border-radius: 4px;
background: #fff;
font-weight: 600;
font-size: 16px;
position: relative;
top: 50%;
outline-color: transparent;
border: none;
}
.current-caption button:hover {
border-color: transparent;
border: none;
}
.current-caption button:focus {
border-color: transparent;
border: none;
}
.current-caption button .fa {
margin-right: 5px;
}
.seclected {
display: none;
}
<div class="lg-current-inner">
<div class="lg-each-contest">
<div class="lg-current-banner">
<img src="assets/images/gl-1.jpg" alt="" class="img-responsive">
<span class="amount">$130</span>
</div>
<div class="lg-current-content">
<h3>Logo Name here</h3>
<p>We are looking for a clean logol company strickt.</p>
</div>
<div class="current-caption">
<button class="select-btn">
<span class="select">Select</span>
<span class="seclected select">Selected</span>
</button>
</div>
</div>
<div class="time">
<div class="remaning-time">
<span class="each-time"> 25 Days 13 Hours 00 min</span>
<span class="pull-right submissions" data-toggle="tooltip" data-placement="top" title="Submissions" data-toggle="tooltip" data-placement="top" title="Submissions">344</span>
</div>
</div>
</div>
check demo: http://codepen.io/anon/pen/MpoMad?editors=1100
thanks in advance.
I hope this is what you are looking for. Add a z-index for your div this will avoid that text from appearing on the hover div, as well as the padding seems to be unwanted I have removed that too.
<!DOCTYPE html>
<html>
<head>
<style>
.lg-current-inner {
border: 1px solid #bdbdbd;
margin-bottom: 30px;
position: relative;
}
.lg-each-contest {
overflow: hidden;
position: relative;
}
.lg-each-contest:hover .current-caption {
opacity: 1;
}
.lg-current-banner .amount {
position: absolute;
top: 5px;
background-color: #fea700;
padding: 5px 12px;
font-size: 22px;
right: 0;
font-weight: 600;
color: #fff;
}
.lg-current-content {
padding: 10px;
}
.lg-current-content h3 {
font-size: 24px;
line-height: 36px;
margin-top: 10px;
}
.time {
border-top: 1px solid #bdbdbd;
position: relative;
}
.time .remaning-time {
padding: 10px;
}
.time .remaning-time .each-time {
font-size: 14px;
font-weight: 500;
}
.time .remaning-time .submissions {
padding: 2px 10px;
background: #1bcd80;
font-weight: 500;
color: #fff;
border-radius: 2px;
}
.current-caption {
position: absolute;
top: 0;
left: 0;
cursor: pointer;
right: 0;
bottom: 0;
/*padding: 25% 0;*/
z-index: 10000;
width: 100%;
height: 100%;
background-color: rgba(63, 97, 132, 0.5);
text-align: center;
font-size: 15px;
opacity: 0;
-webkit-transition: all 0.4s ease-out;
-moz-transition: all 0.4s ease-out;
-o-transition: all 0.4s ease-out;
-ms-transition: all 0.4s ease-out;
transition: all 0.4s ease-out;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.current-caption button {
color: #fea700;
padding: 6px 20px;
opacity: 1;
border-radius: 4px;
background: #fff;
font-weight: 600;
font-size: 16px;
position: relative;
top: 50%;
outline-color: transparent;
border: none;
}
.current-caption button:hover {
border-color: transparent;
border: none;
}
.current-caption button:focus {
border-color: transparent;
border: none;
}
.current-caption button .fa {
margin-right: 5px;
}
.seclected {
display: none;
}
</style>
</head>
<body>
<div class="col-sm-3 wow fadeInRight" data-wow-delay="0.2s">
<div class="lg-current-inner">
<div class="lg-each-contest">
<div class="lg-current-banner">
<img src="assets/images/gl-1.jpg" alt="" class="img-responsive">
<span class="amount">$130</span>
</div>
<div class="lg-current-content">
<h3>Logo Name here</h3>
<p>We are looking for a clean logo that pops apparel company strickt.</p>
</div>
<div class="current-caption">
<button class="select-btn">
<span class="select">Select</span>
<span class="seclected select"><i class="fa fa-check-circle"></i>Selected</span>
</button>
</div>
</div>
<div class="time">
<div class="remaning-time">
<span class="each-time"><i class="fa fa-calendar"></i> 25 Days 13 Hours 00 min</span>
<span class="pull-right submissions" data-toggle="tooltip" data-placement="top" title="Submissions" data-toggle="tooltip" data-placement="top" title="Submissions">344</span>
</div>
</div>
</div>
</div>
</body>
</html>
Modifications.
Set overflow: hidden and position: relative for the lg-each-contest class. This will stops the overflow of the hovering div. I have updated the code.
I have no idea about what you are asking. But when I run the code I saw the cursor is not showing the pointer on the button. I just add some code to your CSS file.
.current-caption button {
+ cursor: pointer;
}
.current-caption button:hover {
+ background: #000;
}
.current-caption must be on top while .lg-each-contest is hovering only
.lg-current-inner {
border: 1px solid #bdbdbd;
margin-bottom: 30px;
position: relative;
}
.lg-each-contest:hover .current-caption {
opacity: 1;
z-index:2; /* added */
}
.lg-current-banner .amount {
position: absolute;
top: 5px;
background-color: #fea700;
padding: 5px 12px;
font-size: 22px;
right: 0;
font-weight: 600;
color: #fff;
}
.lg-current-content {
padding: 10px;
}
.lg-current-content h3 {
font-size: 24px;
line-height: 36px;
margin-top: 10px;
}
.time {
border-top: 1px solid #bdbdbd;
position: relative;
}
.time .remaning-time {
padding: 10px;
}
.time .remaning-time .each-time {
font-size: 14px;
font-weight: 500;
}
.time .remaning-time .submissions {
padding: 2px 10px;
background: #1bcd80;
font-weight: 500;
color: #fff;
border-radius: 2px;
}
.current-caption {
position: absolute;
top: 0;
left: 0;
cursor: pointer;
right: 0;
bottom: 0;
/*padding: 25% 0;*/ /* removed */
width: 100%;
height: 100%;
background-color: rgba(63, 97, 132, 0.5);
text-align: center;
font-size: 15px;
opacity: 0;
-webkit-transition: all 0.4s ease-out;
-moz-transition: all 0.4s ease-out;
-o-transition: all 0.4s ease-out;
-ms-transition: all 0.4s ease-out;
transition: all 0.4s ease-out;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.current-caption button {
color: #fea700;
padding: 6px 20px;
opacity: 1;
border-radius: 4px;
background: #fff;
font-weight: 600;
font-size: 16px;
position: relative;
top: 50%;
outline-color: transparent;
border: none;
}
.current-caption button:hover {
border-color: transparent;
border: none;
}
.current-caption button:focus {
border-color: transparent;
border: none;
}
.current-caption button .fa {
margin-right: 5px;
}
.seclected {
display: none;
}
<div class="lg-current-inner">
<div class="lg-each-contest">
<div class="lg-current-banner">
<img src="assets/images/gl-1.jpg" alt="" class="img-responsive">
<span class="amount">$130</span>
</div>
<div class="lg-current-content">
<h3>Logo Name here</h3>
<p>We are looking for a clean logol company strickt.</p>
</div>
<div class="current-caption">
<button class="select-btn">
<span class="select">Select</span>
<span class="seclected select">Selected</span>
</button>
</div>
</div>
<div class="time">
<div class="remaning-time">
<span class="each-time"> 25 Days 13 Hours 00 min</span>
<span class="pull-right submissions" data-toggle="tooltip" data-placement="top" title="Submissions" data-toggle="tooltip" data-placement="top" title="Submissions">344</span>
</div>
</div>
</div>
here just added z-index
.lg-each-contest:hover .current-caption {
++ z-index:2;
}
removed padding to fit container
.current-caption {
-- padding: 25% 0;
}

Horizontally center image and use max width overlay also when image width is smaller

My image is inside a well which has fixed width fixed.
(1) How to get my image always horizontally centered (I tried using
margin:0 auto but it didnt work).
(2) Also I have an .overlay
and it works for all my other images (which have the
max-width:300px, but for images as in example with smaller width,
I need the overlay to also cover a full max-width of the well (now as in this example, the overlay is limited to the width of these smaller-width images). How to make
these 2 things possible?
.image-video-linkcar {
position: relative;
display: inline-block;
}
.image-video-linkcar img {
max-width: auto;
max-height: 230px;
margin: 0;
padding: 0;
vertical-align: middle;
}
.categorycar {
font-size: 10px;
font-weight: 700;
font-family: 'Montserrat',sans-serif;
font-style: bold;
text-align: center;
color: #777;
margin-left: 15px;
outline: 1px solid #fff;
padding: 2px 20px 2px 8px;
background-color: #FFF;
opacity: .9;
position: absolute;
opacity: .7;
bottom: 0;
right: 0;
min-height: 0;
}
.brandcar {
font-size: 10px;
font-weight: 700;
font-family: 'Montserrat',sans-serif;
font-style: bold;
text-align: center;
color: #777;
margin-left: 15px;
outline: 1px solid #fff;
padding: 2px 20px 2px 8px;
background-color: #fff;
opacity: .9;
position: absolute;
opacity: .7;
top: 0;
right: 0;
min-height: 0;
}
.image-video-linkcar:hover .overlay {
opacity: 1;
}
.well.carousel {
width: 100%;
height: auto;
height: 420px;
width: 400px;
padding: 0;
margin: 0;
border: none;
background-color:red
}
.product-detailscar .overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
opacity: 0;
border-radius: 0;
background: #F7F7F7;
color: #FFF;
padding: 10px;
border-top: 1px solid #A10000;
border-bottom: 1px solid #A10000;
/*vertical-align: middle;*/
-webkit-transition: opacity 500ms;
-moz-transition: opacity 500ms;
-o-transition: opacity 500ms;
transition: opacity 500ms;
/*padding: 25px;
text-align: center;*/
}
<div class="well carousel">
<div class="product-detailscar">
<div class="image-video-linkcar">
<img alt="#" src=
"http://lorempixel.com/100/200">
<div class="brandcar">
BRAND
</div>
<div class="categorycar">
CATEGORY
</div>
<div class="overlay">
<div class="subcategorycar">
SUBCAT
</div>
<div class="idcar">
ID
</div>
You need to move the overlay out of the .product-detailscar div.
.well {
width: 300px;
background: orange;
position: relative;
text-align: center;
}
.image-video-linkcar {
position: relative;
display: inline-block;
}
.image-video-linkcar img {
max-width: auto;
max-height: 230px;
margin: 0;
padding: 0;
vertical-align: middle;
}
.categorycar {
font-size: 10px;
font-weight: 700;
font-family: 'Montserrat', sans-serif;
font-style: bold;
text-align: center;
color: #777;
margin-left: 15px;
outline: 1px solid #fff;
padding: 2px 20px 2px 8px;
background-color: #FFF;
opacity: .9;
position: absolute;
opacity: .7;
bottom: 0;
right: 0;
min-height: 0;
}
.brandcar {
font-size: 10px;
font-weight: 700;
font-family: 'Montserrat', sans-serif;
font-style: bold;
text-align: center;
color: #777;
margin-left: 15px;
outline: 1px solid #fff;
padding: 2px 20px 2px 8px;
background-color: #fff;
opacity: .9;
position: absolute;
opacity: .7;
top: 0;
right: 0;
min-height: 0;
}
.well:hover .overlay {
opacity: 1;
}
.well .overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
opacity: 0;
border-radius: 0;
background: rgba(0, 255, 0, .5);
color: #FFF;
padding: 10px;
border-top: 1px solid #A10000;
border-bottom: 1px solid #A10000;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<div class="well carousel">
<div class="product-detailscar">
<div class="image-video-linkcar">
<img alt="#" src="http://www.fillmurray.com/100/200">
<div class="brandcar">
BRAND
</div>
<div class="categorycar">
CATEGORY
</div>
</div>
</div>
<div class="overlay">
<div class="subcategorycar">
SUBBBBBBCATEGORY
</div>
<div class="idcar">
IDDDDCAR
</div>
</div>
</div>

position: relative; interrupts css opacity in web page

When adding position: relative; to the code the background popup window won't get any opacity - what is the reason for that? I don't understand why centering the web page should affect background opacity.
Thanks for anyone that can help!!
<html>
<head>
<style>
body {
background-color: white;
width: 960px;
margin: auto;
position: relative;
}
.one {
background: black;
-webkit-border-radius: 12;
-moz-border-radius: 12;
border-radius: 12px;
font-family: Book Antiqua;
color: #ffffff;
font-size: 60px;
text-align: center;
width: 75px;
height: 75px;
overflow:hidden;
float:left;
position:absolute;
transition: .5s ease;
top: 120px;
left: 140px;
text-align: center;
text-vertical-align: middle;
}
.overlay {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: rgba(0, 0, 0, 0.8);;
transition: opacity 500ms;
visibility: hidden;
opacity: 0;
}
.overlay:target {
visibility: visible;
opacity: 1;
}
.popup {
margin: 70px auto;
padding: 20px;
background: #fff;
border-radius: 5px;
width: 30%;
position: relative;
transition: all 5s ease-in-out;
}
.popup h2 {
margin-top: 0;
color: #333;
font-family: Tahoma, Arial, sans-serif;
}
.popup .close {
position: absolute;
top: 20px;
right: 30px;
transition: all 200ms;
font-size: 30px;
font-weight: bold;
text-decoration: none;
color: #333;
}
.popup .close:hover {
color: orange;
}
.popup .content {
max-height: 30%;
overflow: auto;
}
</style>
</head>
<body>
<a class="one" id="one" href="#popup1" onclick="changeZIndex(this)">1</a>
<div id="popup1" class="overlay">
<div class="popup">
<h2>Here i am</h2>
<a class="close" href="#">×</a>
<div class="content">
1
</div>
</div>
</div>
</body>
</html>
Link
Add height to the html and body element
CSS
html,
body
{
height: 100%;
}
CSS Errors
.one
{
background: black;
-webkit-border-radius: 12;
-moz-border-radius: 12;
border-radius: 12px;
font-family: Book Antiqua;
color: #ffffff;
font-size: 60px;
text-align: center;
width: 75px;
height: 75px;
overflow: hidden;
float: left;
position: absolute;
transition: .5s ease;
top: 120px;
left: 140px;
text-align: center;
/* incorrect value
text-vertical-align: middle;
*/
}
.overlay {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: rgba(0, 0, 0, 0.8);
/*
transition: opacity 500ms;
*/
transition: opacity 0.5s;
visibility: hidden;
opacity: 0;
}

How to make a pop up?

I'm just wondering how something like this is done
I searched on google but I only found informations about ad pop ups
Thanks in advance
There you go,
<h1>Popup without JavaScript</h1>
<div class="box">
<a class="button" href="#popup1">Let me Pop up</a>
</div>
<div id="popup1" class="overlay">
<div class="popup">
<h2>Here i am</h2>
<a class="close" href="#">×</a>
<div class="content">
Thanks for pop me out of that button, but now i'm done so you can close this window.
</div>
</div>
</div>
**CSS**
body {
font-family: Arial, sans-serif;
background: url(4.jpg);
background-size: cover;
}
h1 {
text-align: center;
font-family: Tahoma, Arial, sans-serif;
color: orange;
margin: 100px 0;
}
.box {
width: 20%;
margin: 0 auto;
background: rgba(255,255,255,0.2);
padding: 35px;
border: 2px solid #fff;
border-radius: 20px/50px;
background-clip: padding-box;
text-align: center;
}
.button {
font-size: 1em;
padding: 10px;
color: #fff;
border: 2px solid orange;
border-radius: 20px/50px;
text-decoration: none;
cursor: pointer;
transition: all 0.3s ease-out;
}
.button:hover {
background: orange;
}
.overlay {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: rgba(0, 0, 0, 0.7);
transition: opacity 500ms;
visibility: hidden;
opacity: 0;
}
.overlay:target {
visibility: visible;
opacity: 1;
}
.popup {
margin: 70px auto;
padding: 20px;
background: #fff;
border-radius: 5px;
width: 30%;
position: relative;
transition: all 5s ease-in-out;
}
.popup h2 {
margin-top: 0;
color: #333;
font-family: Tahoma, Arial, sans-serif;
}
.popup .close {
position: absolute;
top: 20px;
right: 30px;
transition: all 200ms;
font-size: 30px;
font-weight: bold;
text-decoration: none;
color: #333;
}
.popup .close:hover {
color: orange;
}
.popup .content {
max-height: 30%;
overflow: auto;
}
Try the snippet below:
html, body{
width: 100%;
height: 100%;
padding: 0;
margin: 0;
}
.container{
width:100%;
height: 100%;
margin: 0;
position: absolute;
background: rgba(220,220,220, .5);
}
.modal{
position: relative;
top: 40%;
margin: 0 auto;
height: 100px;
width: 150px;
background: white;
border: 1px solid #aaa;
}
p{
margin: 0;
}
<div class='container'>
<div class='modal'>Modal window</div>
</div>
<p> other content</p>
Try with absolute positioned container div and a child div with actual content. I added paragraph with content Other content to illustrate the effect