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;
}
Related
Trying to make a responsive design.
There are 3 buttons with a background, the buttons which are to the bottom, disappearing when I have 900px height.
I tried max-height: 900px with overflow-y: auto; but the buttons disappeared and it was just the logo and the text after.
as i can see in the run code you cant see the buttons as the height is low and it wont scroll
```css
body {
background-color: black;
background: linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7)),url("../Bloc\ Nisipari/View03.jpg") no-repeat center center fixed;
-webkit-background-size: cover; /* For WebKit*/
-moz-background-size: cover; /* Mozilla*/
-o-background-size: cover; /* Opera*/
background-size: cover; /* Generic*/
margin: 0;
width: 90%;
height: 100%;
max-width: 100%;
overflow: hidden;
max-height: 750px;
}
div1
{
color: white;
position: relative;
left:200px;
top:300px;
width: 200px;
height: auto;
margin: auto;
font-size:24px;
font-family: 'montserrat';
src : url("../Montserrat/Montserrat-Italic-VariableFont_wght.ttf");
}
.textlogo
{
width: 500px;
}
.logo{
width: 300px;
}
.container
{
position: relative;
left: 200px;
top: 500px;
width:100%;
height: auto;
min-height: 100vmax;
margin: auto;
font-family: 'montserrat';
src : url("../Montserrat/Montserrat-Italic-VariableFont_wght.ttf")
}
.btn-1
{
width: 200px;
height: 60px;
border: none;
color: rgb(255, 255, 255);
transition: ease-out 0.3s;
background-color: transparent;
font-size:32px;
outline:none;
position: relative;
z-index:1;
font-family: 'montserrat';
src : url("../Montserrat/Montserrat-Italic-VariableFont_wght.ttf")
}
.btn-1:hover{
color: rgb(0, 0, 0);
cursor: pointer;
text-decoration: none;
}
.btn-1:before{
transition: 0.5s all ease;
position: absolute;
top: 0;
left: 150%;
right: 150%;
bottom: 0;
opacity: 0;
content:"";
background-color: #ffffff;
}
.btn-1:hover::before{
transition: 0.5 all ease;
left: 0;
right: 0;
opacity:1;
z-index: -1;
}
.btn-2
{
width: 200px;
height: 60px;
border: none;
color: rgb(255, 255, 255);
transition: ease-out 0.3s;
background-color: transparent;
font-size:32px;
outline:none;
position: relative;
z-index:1;
font-family: 'montserrat';
src : url("../Montserrat/Montserrat-Italic-VariableFont_wght.ttf")
}
.btn-2:hover{
color: rgb(0, 0, 0);
cursor: pointer;
text-decoration: none;
}
.btn-2:before{
transition: 0.5s all ease;
position: absolute;
top: 0;
left: 50%;
right: 50%;
bottom: 0;
opacity: 0;
content:"";
background-color: #ffffff;
}
.btn-2:hover::before{
transition: 0.5 all ease;
left: 0;
right: 0;
opacity:1;
z-index: -1;
}
.btn-3
{
width: 200px;
height: 60px;
border: none;
color: rgb(255, 255, 255);
transition: ease-out 0.3s;
background-color: transparent;
font-size:32px;
outline:none;
position: relative;
z-index:1;
font-family: 'montserrat';
src : url("../Montserrat/Montserrat-Italic-VariableFont_wght.ttf")
}
.btn-3:hover{
color: rgb(0, 0, 0);
cursor: pointer;
text-decoration: none;
}
.btn-3:before{
transition: 0.5s all ease;
position: absolute;
top: 0;
left: 50%;
right: 50%;
bottom: 0;
opacity: 0;
content:"";
background-color: #ffffff;
}
.btn-3:hover::before{
transition: 0.5 all ease;
left: 0;
right: -13%;
opacity:1;
z-index: -1;
}
#media only screen and (max-width: 900px)
{
div1
{
color: white;
position: fixed;
left: 60px;
top:50px;
width: 300px; /*Takes 90% width from WebContainer*/
height: auto;
margin: auto;
font-size:18px;
font-family: 'montserrat';
src : url("../Montserrat/Montserrat-Italic-VariableFont_wght.ttf")
}
.textlogo
{
width:90%
}
.logo
{
display:block;
margin-left: auto;
margin-right: auto;
top: 50px;
width: 200px;
}
.container
{
position: fixed;
left: 60px;
top: 300px;
width:200px; /*Takes 90% width from WebContainer*/
height: auto;
margin: auto;
font-family: 'montserrat';
src : url("../Montserrat/Montserrat-Italic-VariableFont_wght.ttf")
}
.btn-1
{
width: 200px;
height: 60px;
border: none;
color: rgb(255, 255, 255);
top: 50px;
left: 30px;
font-size:32px;
transition: ease-out 0.3s;
background-color: transparent;
outline:none;
position: relative;
z-index:1;
font-family: 'montserrat';
src : url("../Montserrat/Montserrat-Italic-VariableFont_wght.ttf")
}
.btn-1:hover{
color: rgb(0, 0, 0);
cursor: pointer;
text-decoration: none;
}
.btn-1:before{
transition: 0.5s all ease;
position: absolute;
top: 0;
left: 150%;
right: 150%;
bottom: 0;
opacity: 0;
content:"";
background-color: #ffffff;
}
.btn-1:hover::before{
transition: 0.5 all ease;
left: 0;
right: 0;
opacity:1;
z-index: -1;
}
.btn-2
{
width: 200px;
height: 60px;
border: none;
color: rgb(255, 255, 255);
top: 100px;
left: 30px;
transition: ease-out 0.3s;
background-color: transparent;
font-size:32px;
outline:none;
position: relative;
z-index:1;
font-family: 'montserrat';
src : url("../Montserrat/Montserrat-Italic-VariableFont_wght.ttf")
}
.btn-2:hover{
color: rgb(0, 0, 0);
cursor: pointer;
text-decoration: none;
}
.btn-2:before{
transition: 0.5s all ease;
position: absolute;
top: 0;
left: 50%;
right: 50%;
bottom: 0;
opacity: 0;
content:"";
background-color: #ffffff;
}
.btn-2:hover::before{
transition: 0.5 all ease;
left: 0;
right: 0;
opacity:1;
z-index: -1;
}
.btn-3
{
width: 200px;
height: 60px;
border: none;
color: rgb(255, 255, 255);
top: 150px;
left: 30px;
transition: ease-out 0.3s;
background-color: transparent;
font-size:32px;
outline:none;
position: relative;
z-index:1;
font-family: 'montserrat';
src : url("../Montserrat/Montserrat-Italic-VariableFont_wght.ttf")
}
.btn-3:hover{
color: rgb(0, 0, 0);
cursor: pointer;
text-decoration: none;
}
.btn-3:before{
transition: 0.5s all ease;
position: absolute;
top: 0;
left: 50%;
right: 50%;
bottom: 0;
opacity: 0;
content:"";
background-color: #ffffff;
}
.btn-3:hover::before{
transition: 0.5 all ease;
left: -5%;
right: -20%;
opacity:1;
z-index: -1;
}
}
#media only screen and (max-width: 350px)
{
div1
{
color: white;
position: fixed;
left: 10px;
width: 250px;
height: auto;
margin: auto;
font-size:18px;
font-family: 'montserrat';
src : url("../Montserrat/Montserrat-Italic-VariableFont_wght.ttf")
}
.textlogo
{
width: 240px;
margin-left: auto;
}
.logo
{
display:block;
margin-left: auto;
margin-right: auto;
}
.container
{
position: fixed;
left: 00px;
top: 300px;
width:200px; /*Takes 90% width from WebContainer*/
height: auto;
margin: auto;
font-family: 'montserrat';
src : url("../Montserrat/Montserrat-Italic-VariableFont_wght.ttf")
}
.btn-1
{
width: 200px;
height: 60px;
border: none;
color: rgb(255, 255, 255);
top: 20px;
margin-left: auto;
margin-right: auto;
font-size:32px;
transition: ease-out 0.3s;
background-color: transparent;
outline:none;
position: relative;
z-index:1;
font-family: 'montserrat';
src : url("../Montserrat/Montserrat-Italic-VariableFont_wght.ttf")
}
.btn-1:hover{
color: rgb(0, 0, 0);
cursor: pointer;
text-decoration: none;
}
.btn-1:before{
transition: 0.5s all ease;
position: absolute;
top: 0;
left: 150%;
right: 150%;
bottom: 0;
opacity: 0;
content:"";
background-color: #ffffff;
}
.btn-1:hover::before{
transition: 0.5 all ease;
left: 0;
right: 0;
opacity:1;
z-index: -1;
}
.btn-2
{
width: 200px;
height: 60px;
border: none;
color: rgb(255, 255, 255);
top: 30px;
margin-left: auto;
margin-right: auto;
transition: ease-out 0.3s;
background-color: transparent;
font-size:32px;
outline:none;
position: relative;
z-index:1;
font-family: 'montserrat';
src : url("../Montserrat/Montserrat-Italic-VariableFont_wght.ttf")
}
.btn-2:hover{
color: rgb(0, 0, 0);
cursor: pointer;
text-decoration: none;
}
.btn-2:before{
transition: 0.5s all ease;
position: absolute;
top: 0;
left: 50%;
right: 50%;
bottom: 0;
opacity: 0;
content:"";
background-color: #ffffff;
}
.btn-2:hover::before{
transition: 0.5 all ease;
left: 0;
right: 0;
opacity:1;
z-index: -1;
}
.btn-3
{
width: 200px;
height: 60px;
border: none;
color: rgb(255, 255, 255);
top: 40px;
margin-left: auto;
margin-right: auto;
transition: ease-out 0.3s;
background-color: transparent;
font-size:32px;
outline:none;
position: relative;
z-index:1;
font-family: 'montserrat';
src : url("../Montserrat/Montserrat-Italic-VariableFont_wght.ttf")
}
.btn-3:hover{
color: rgb(0, 0, 0);
cursor: pointer;
text-decoration: none;
}
.btn-3:before{
transition: 0.5s all ease;
position: absolute;
top: 0;
left: 50%;
right: 50%;
bottom: 0;
opacity: 0;
content:"";
background-color: #ffffff;
}
.btn-3:hover::before{
transition: 0.5 all ease;
left: -5%;
right: -20%;
opacity:1;
z-index: -1;
}
}
body {
background-color: black;
background: linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7)),url("../Bloc\ Nisipari/View03.jpg") no-repeat center center fixed;
-webkit-background-size: cover; /* For WebKit*/
-moz-background-size: cover; /* Mozilla*/
-o-background-size: cover; /* Opera*/
background-size: cover; /* Generic*/
margin: 0;
width: 90%;
height: 100%;
max-width: 100%;
overflow: hidden;
max-height: 750px;
}
div1
{
color: white;
position: relative;
left:200px;
top:300px;
width: 200px;
height: auto;
margin: auto;
font-size:24px;
font-family: 'montserrat';
src : url("../Montserrat/Montserrat-Italic-VariableFont_wght.ttf");
}
.textlogo
{
width: 500px;
}
.logo{
width: 300px;
}
.container
{
position: relative;
left: 200px;
top: 500px;
width:100%;
height: auto;
min-height: 100vmax;
margin: auto;
font-family: 'montserrat';
src : url("../Montserrat/Montserrat-Italic-VariableFont_wght.ttf")
}
.btn-1
{
width: 200px;
height: 60px;
border: none;
color: rgb(255, 255, 255);
transition: ease-out 0.3s;
background-color: transparent;
font-size:32px;
outline:none;
position: relative;
z-index:1;
font-family: 'montserrat';
src : url("../Montserrat/Montserrat-Italic-VariableFont_wght.ttf")
}
.btn-1:hover{
color: rgb(0, 0, 0);
cursor: pointer;
text-decoration: none;
}
.btn-1:before{
transition: 0.5s all ease;
position: absolute;
top: 0;
left: 150%;
right: 150%;
bottom: 0;
opacity: 0;
content:"";
background-color: #ffffff;
}
.btn-1:hover::before{
transition: 0.5 all ease;
left: 0;
right: 0;
opacity:1;
z-index: -1;
}
.btn-2
{
width: 200px;
height: 60px;
border: none;
color: rgb(255, 255, 255);
transition: ease-out 0.3s;
background-color: transparent;
font-size:32px;
outline:none;
position: relative;
z-index:1;
font-family: 'montserrat';
src : url("../Montserrat/Montserrat-Italic-VariableFont_wght.ttf")
}
.btn-2:hover{
color: rgb(0, 0, 0);
cursor: pointer;
text-decoration: none;
}
.btn-2:before{
transition: 0.5s all ease;
position: absolute;
top: 0;
left: 50%;
right: 50%;
bottom: 0;
opacity: 0;
content:"";
background-color: #ffffff;
}
.btn-2:hover::before{
transition: 0.5 all ease;
left: 0;
right: 0;
opacity:1;
z-index: -1;
}
.btn-3
{
width: 200px;
height: 60px;
border: none;
color: rgb(255, 255, 255);
transition: ease-out 0.3s;
background-color: transparent;
font-size:32px;
outline:none;
position: relative;
z-index:1;
font-family: 'montserrat';
src : url("../Montserrat/Montserrat-Italic-VariableFont_wght.ttf")
}
.btn-3:hover{
color: rgb(0, 0, 0);
cursor: pointer;
text-decoration: none;
}
.btn-3:before{
transition: 0.5s all ease;
position: absolute;
top: 0;
left: 50%;
right: 50%;
bottom: 0;
opacity: 0;
content:"";
background-color: #ffffff;
}
.btn-3:hover::before{
transition: 0.5 all ease;
left: 0;
right: -13%;
opacity:1;
z-index: -1;
}
#media only screen and (max-width: 900px)
{
div1
{
color: white;
position: fixed;
left: 60px;
top:50px;
width: 300px; /*Takes 90% width from WebContainer*/
height: auto;
margin: auto;
font-size:18px;
font-family: 'montserrat';
src : url("../Montserrat/Montserrat-Italic-VariableFont_wght.ttf")
}
.textlogo
{
width:90%
}
.logo
{
display:block;
margin-left: auto;
margin-right: auto;
top: 50px;
width: 200px;
}
.container
{
position: fixed;
left: 60px;
top: 300px;
width:200px; /*Takes 90% width from WebContainer*/
height: auto;
margin: auto;
font-family: 'montserrat';
src : url("../Montserrat/Montserrat-Italic-VariableFont_wght.ttf")
}
.btn-1
{
width: 200px;
height: 60px;
border: none;
color: rgb(255, 255, 255);
top: 50px;
left: 30px;
font-size:32px;
transition: ease-out 0.3s;
background-color: transparent;
outline:none;
position: relative;
z-index:1;
font-family: 'montserrat';
src : url("../Montserrat/Montserrat-Italic-VariableFont_wght.ttf")
}
.btn-1:hover{
color: rgb(0, 0, 0);
cursor: pointer;
text-decoration: none;
}
.btn-1:before{
transition: 0.5s all ease;
position: absolute;
top: 0;
left: 150%;
right: 150%;
bottom: 0;
opacity: 0;
content:"";
background-color: #ffffff;
}
.btn-1:hover::before{
transition: 0.5 all ease;
left: 0;
right: 0;
opacity:1;
z-index: -1;
}
.btn-2
{
width: 200px;
height: 60px;
border: none;
color: rgb(255, 255, 255);
top: 100px;
left: 30px;
transition: ease-out 0.3s;
background-color: transparent;
font-size:32px;
outline:none;
position: relative;
z-index:1;
font-family: 'montserrat';
src : url("../Montserrat/Montserrat-Italic-VariableFont_wght.ttf")
}
.btn-2:hover{
color: rgb(0, 0, 0);
cursor: pointer;
text-decoration: none;
}
.btn-2:before{
transition: 0.5s all ease;
position: absolute;
top: 0;
left: 50%;
right: 50%;
bottom: 0;
opacity: 0;
content:"";
background-color: #ffffff;
}
.btn-2:hover::before{
transition: 0.5 all ease;
left: 0;
right: 0;
opacity:1;
z-index: -1;
}
.btn-3
{
width: 200px;
height: 60px;
border: none;
color: rgb(255, 255, 255);
top: 150px;
left: 30px;
transition: ease-out 0.3s;
background-color: transparent;
font-size:32px;
outline:none;
position: relative;
z-index:1;
font-family: 'montserrat';
src : url("../Montserrat/Montserrat-Italic-VariableFont_wght.ttf")
}
.btn-3:hover{
color: rgb(0, 0, 0);
cursor: pointer;
text-decoration: none;
}
.btn-3:before{
transition: 0.5s all ease;
position: absolute;
top: 0;
left: 50%;
right: 50%;
bottom: 0;
opacity: 0;
content:"";
background-color: #ffffff;
}
.btn-3:hover::before{
transition: 0.5 all ease;
left: -5%;
right: -20%;
opacity:1;
z-index: -1;
}
}
#media only screen and (max-width: 350px)
{
div1
{
color: white;
position: fixed;
left: 10px;
width: 250px;
height: auto;
margin: auto;
font-size:18px;
font-family: 'montserrat';
src : url("../Montserrat/Montserrat-Italic-VariableFont_wght.ttf")
}
.textlogo
{
width: 240px;
margin-left: auto;
}
.logo
{
display:block;
margin-left: auto;
margin-right: auto;
}
.container
{
position: fixed;
left: 00px;
top: 300px;
width:200px; /*Takes 90% width from WebContainer*/
height: auto;
margin: auto;
font-family: 'montserrat';
src : url("../Montserrat/Montserrat-Italic-VariableFont_wght.ttf")
}
.btn-1
{
width: 200px;
height: 60px;
border: none;
color: rgb(255, 255, 255);
top: 20px;
margin-left: auto;
margin-right: auto;
font-size:32px;
transition: ease-out 0.3s;
background-color: transparent;
outline:none;
position: relative;
z-index:1;
font-family: 'montserrat';
src : url("../Montserrat/Montserrat-Italic-VariableFont_wght.ttf")
}
.btn-1:hover{
color: rgb(0, 0, 0);
cursor: pointer;
text-decoration: none;
}
.btn-1:before{
transition: 0.5s all ease;
position: absolute;
top: 0;
left: 150%;
right: 150%;
bottom: 0;
opacity: 0;
content:"";
background-color: #ffffff;
}
.btn-1:hover::before{
transition: 0.5 all ease;
left: 0;
right: 0;
opacity:1;
z-index: -1;
}
.btn-2
{
width: 200px;
height: 60px;
border: none;
color: rgb(255, 255, 255);
top: 30px;
margin-left: auto;
margin-right: auto;
transition: ease-out 0.3s;
background-color: transparent;
font-size:32px;
outline:none;
position: relative;
z-index:1;
font-family: 'montserrat';
src : url("../Montserrat/Montserrat-Italic-VariableFont_wght.ttf")
}
.btn-2:hover{
color: rgb(0, 0, 0);
cursor: pointer;
text-decoration: none;
}
.btn-2:before{
transition: 0.5s all ease;
position: absolute;
top: 0;
left: 50%;
right: 50%;
bottom: 0;
opacity: 0;
content:"";
background-color: #ffffff;
}
.btn-2:hover::before{
transition: 0.5 all ease;
left: 0;
right: 0;
opacity:1;
z-index: -1;
}
.btn-3
{
width: 200px;
height: 60px;
border: none;
color: rgb(255, 255, 255);
top: 40px;
margin-left: auto;
margin-right: auto;
transition: ease-out 0.3s;
background-color: transparent;
font-size:32px;
outline:none;
position: relative;
z-index:1;
font-family: 'montserrat';
src : url("../Montserrat/Montserrat-Italic-VariableFont_wght.ttf")
}
.btn-3:hover{
color: rgb(0, 0, 0);
cursor: pointer;
text-decoration: none;
}
.btn-3:before{
transition: 0.5s all ease;
position: absolute;
top: 0;
left: 50%;
right: 50%;
bottom: 0;
opacity: 0;
content:"";
background-color: #ffffff;
}
.btn-3:hover::before{
transition: 0.5 all ease;
left: -5%;
right: -20%;
opacity:1;
z-index: -1;
}
}
<div1>
<img class="logo" src="../site/image/logo.png" alt="logo">
<p class="textlogo">"Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit..."</p>
</div1>
<div class="container">
<button class="btn-1"><span>proiectare</span></button>
<button class="btn-2"><span>constructii</span></button>
<button class="btn-3"><span>infrastructura</span></button>
</div>
<h1> </h1>
<p>
</p>
here is a simplified version of my webpage. I am experiencing an issue where my buttons ( tags) are overlapping my main h1 element. How can I fix this, so they do not overlap? I believe that the issue is being caused because I have set the position of the div #MOVE to fixed. However, I need this due to my animated navigation bar.
HTML:
<!DOCTYPE html>
<html>
<head>
<link href="main.css" rel="stylesheet" type="text/css">
<script src="jquery-1.10.2.min.js">
</script>
<script src="main.js">
</script>
<title>A'S COFFEE</title>
</head>
<body>
<div id="MOVE">
<h1 class="logoone">COFFEE.</h1>
<h1 class="logotwo">BETTER WITH A'S</h1>
</div>
<div class="centeralign">
<a class="button" href="place.html" id="btn1">Want to Place<br>
an Order?</a><br>
<a class="button" href="#" id="btn2">View Orders?</a>
</div>
<footer></footer>
</body>
</html>
CSS:
h1{
color: #e5b78e;
font-family: Arial;
font-size: 100pt;
padding: 0px;
margin: 0px;
display: block;
}
.logoone{
margin-left: 50px;
padding-top: 40px;
letter-spacing: 15px;
}
.logotwo{
margin-left: 50px;
margin-bottom: 70px;
letter-spacing: 15px;
}
body{
background: url("../img/image3.jpg") no-repeat center center fixed;
background-size: cover;
}
.button{
text-decoration: none;
padding: 30px;
background-color: white;
opacity: 0.5;
font-family: arial;
font-size: 25pt;
text-transform: uppercase;
font-weight: bolder;
color: #202530;
border-radius: 1px;
transition: opacity .2s ease-out;
margin-top: 10px;
letter-spacing: 4px;
}
.button a{
color: rgba(0,0,0,0.5);
}
#btn1{
margin-top:30px;
display: inline-block;
padding-left: 30px;
padding-right:30px;
}
#btn2{
margin-top:30px;
display: inline-block;
padding-left: 47px;
padding-right: 47px;
}
.button:hover{
opacity: 1;
transition: opacity .2s ease-in;
}
.centeralign{
text-align: center;
}
br{
padding: 40px;
}
/* NAV */
#MenuIcon{
height: 25px;
width: 50px;
position: fixed;
top:50;
right: 50;
}
#MenuIcon:hover{
cursor: pointer;
}
#MenuLine{
height: 4px;
width: 50px;
background-color: #e5b78e;
position: absolute;
top:50%;
left: 50%;
transform: translate(-50%,-50%);
transition: all .3s;
}
#MenuIcon:hover #MenuLine{
width: 40px;
}
#MenuLine::before{
content: '';
height: 4px;
width: 40px;
background-color: #e5b78e;
position: absolute;
margin-top: 10px;
transition: all .3s;
}
#MenuIcon:hover #MenuLine::before{
width: 50px;
}
#MenuLine::after{
content: '';
height: 4px;
width: 40px;
background-color: #e5b78e;
position: absolute;
margin-top: -10px;
transition: all .3s;
}
#MenuIcon:hover #MenuLine::after{
width: 50px;
}
#MainMenu{
height: 100vh;
width: 300px;
background-color: #181818;
-webkit-clip-path:polygon(0 0,100% 0,0% 100%,0% 100%);
position: fixed;
top:0;
left: -300px;
transition: all .5s ease-in-out;
}
ul{
list-style: none;
padding: 0px;
margin: 0px;
font-family: arial;
font-weight: bold;
color:white;
text-align: center;
position: absolute;
top: 55%;
left: 50%;
transform: translate(-50%,-50%);
}
ul li{
margin: 20px;
}
ul li:hover{
cursor: pointer;
}
.line{
height: 2px;
width: 150px;
background-color: white;
margin-top: 10px;
position: absolute;
left: 50%;
transform: translate(-50%);
transition: all .3s;
}
ul li:hover .line{
width: 180px;
}
#logo{
position: absolute;
top:100;
left: 50%;
transform: translate(-50%);
}
#close{
position: absolute;
bottom: 150;
left: 50%;
transform: translate(-50%);
}
#close:hover{
cursor: pointer;
}
.LOGO{
font-size: 4.5em;
}
#MOVE{
position:fixed;
top:0%;
left: 0px;
transition: all .5s ease-in-out;
width:85%;
height: 100%;
}
Try
#MOVE{
position:relative;
top:0%;
left: 0px;
transition: all .5s ease-in-out;
width:85%;
height: 100%;
}
That sets the position relative to other elements within the page
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>
I am trying to position a button 10px off the horizontal center of the screen. This is the button code. The button uses some fancy hovering effect, which doesn't move with the button. How can I put the button 10px off the horizontal center of the screen?
body {
background-color: green;
}
.button-2 {
width: 140px;
height: 50px;
border: 2px solid white;
float: left;
text-align: center;
cursor: pointer;
position: relative;
box-sizing: border-box;
overflow: hidden;
margin: 0 0 40px 50px;
}
.button-2 a {
font-family: arial;
font-size: 16px;
color: white;
text-decoration: none;
line-height: 50px;
transition: all .5s ease;
z-index: 2;
position: relative;
}
.eff-2 {
width: 140px;
height: 50px;
top: -50px;
background: white;
position: absolute;
transition: all .5s ease;
z-index: 1;
}
.button-2:hover .eff-2 {
top: 0;
}
.button-2:hover a {
color: #666;
}
.watch-video-position {}
<div class="watch-video-position">
<div class="button-2 watch-video-position">
<div class="eff-2 watch-video-position"></div>
CLICK ME
</div>
</div>
I have made some changes in the css to class button-2.
.button-2 {
float: none;
margin: 0 auto;
top: 10px;
}
body {
background-color: green;
}
.button-2 {
border: 2px solid white;
box-sizing: border-box;
cursor: pointer;
float: none;
height: 50px;
margin: 0 auto;
overflow: hidden;
position: relative;
text-align: center;
top: 10px;
width: 140px;
}
.button-2 a {
font-family: arial;
font-size: 16px;
color: white;
text-decoration: none;
line-height: 50px;
transition: all .5s ease;
z-index: 2;
position: relative;
}
.eff-2 {
width: 140px;
height: 50px;
top: -50px;
background: white;
position: absolute;
transition: all .5s ease;
z-index: 1;
}
.button-2:hover .eff-2 {
top: 0;
}
.button-2:hover a {
color: #666;
}
.watch-video-position {}
<div class="watch-video-position">
<div class="button-2 watch-video-position">
<div class="eff-2 watch-video-position"></div>
CLICK ME
</div>
</div>
You need to use this:
.top {
position: relative;
}
.top .button-2 {
position: absolute;
left: 50%;
margin-left: -70px;
}
Make sure you add the unique class top to the first <div> and use that to position. You can also use margin and padding on the .top.
body {
background-color: green;
}
.button-2 {
width: 140px;
height: 50px;
border: 2px solid white;
float: left;
text-align: center;
cursor: pointer;
position: relative;
box-sizing: border-box;
overflow: hidden;
margin: 0 0 40px 50px;
}
.button-2 a {
font-family: arial;
font-size: 16px;
color: white;
text-decoration: none;
line-height: 50px;
transition: all .5s ease;
z-index: 2;
position: relative;
}
.eff-2 {
width: 140px;
height: 50px;
top: -50px;
background: white;
position: absolute;
transition: all .5s ease;
z-index: 1;
}
.button-2:hover .eff-2 {
top: 0;
}
.button-2:hover a {
color: #666;
}
.top {
position: relative;
padding-top: 25px;
}
.top .button-2 {
position: absolute;
left: 50%;
margin-left: -70px;
}
<div class="top watch-video-position">
<div class="button-2 watch-video-position">
<div class="eff-2 watch-video-position"></div>
CLICK ME
</div>
</div>
try centering its parent and shifting it within its parent:
body {
background-color: green;
text-align: center;
}
.outer {
width: 200px;
margin: auto;
background-color: blue;
}
.button-2 {
width: 140px;
height: 50px;
border: 2px solid white;
cursor: pointer;
position: relative;
box-sizing: border-box;
overflow: hidden;
margin: 0 0 40px 50px;
}
.button-2 a {
font-family: arial;
font-size: 16px;
color: white;
text-decoration: none;
line-height: 50px;
transition: all .5s ease;
z-index: 2;
position: relative;
}
.eff-2 {
width: 140px;
height: 50px;
top: -50px;
background: white;
position: absolute;
transition: all .5s ease;
z-index: 1;
}
.button-2:hover .eff-2 {
top: 0;
}
.button-2:hover a {
color: #666;
}
.watch-video-position {}
<div class="watch-video-position outer">
<div class="button-2 watch-video-position">
<div class="eff-2 watch-video-position"></div>
CLICK ME
</div>
</div>
try width 90% of div.button-2 and set border and padding to anchor.
body {
background-color: green;
}
.button-2 {
width: 90%;
height: 50px;
float: left;
text-align: center;
cursor: pointer;
position: relative;
box-sizing: border-box;
overflow: hidden;
margin: 0 0 40px 50px;
}
.button-2 a {
font-family: arial;
font-size: 16px;
color: white;
text-decoration: none;
line-height: 50px;
transition: all .5s ease;
z-index: 2;
position: relative;
border: 2px solid white;
padding:15px;
}
.eff-2 {
width: 140px;
height: 50px;
top: -50px;
background: white;
position: absolute;
transition: all .5s ease;
z-index: 1;
}
.button-2:hover .eff-2 {
top: 0;
}
.button-2:hover a {
color: #666;
}
.top {
position: relative;
padding-top: 25px;
}
.top .button-2 {
position: absolute;
left: 50%;
margin-left: -70px;
}
<div class="top watch-video-position">
<div class="button-2 watch-video-position">
<div class="eff-2 watch-video-position"></div>
CLICK ME
</div>
</div>
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