HTML and CSS modal box faded background issue - html

I'm using this modal box made from html and css on my website. It turns out fine for the main part, but I'm having a problem with the background fade.
It somehow only fades the background on the part of the site that appears over the position of the box (in the code). I'm using ID's to identify sections of the site (which is a one-page site) for the links in the menu. All sections that are below the section that contains the modal box, doesn't get faded.
Here is some of the code:
<div class="wrapper">
<a href="#modal" class="btn go">
<img src="img/i3.1.jpg" alt="image" />
</a>
<div id="modal">
<link href="css/modal.css" rel="stylesheet">
<div class="modal-content">
<div class="header">
<h2>Modal Heading</h2>
</div>
<div class="copy">
<p>Sample text in modal</p>
</div>
<div class="cf footer">
Close
</div>
</div>
<div class="overlay"></div>
</div>
And the CSS:
#modal {
left:50%;
margin:-250px 0 0 -40%;
opacity: 0;
position:absolute;
top:-50%;
visibility: hidden;
width:80%;
box-shadow:0 3px 7px rgba(0,0,0,.25);
box-sizing:border-box;
transition: all 0.4s ease-in-out;
-moz-transition: all 0.4s ease-in-out;
-webkit-transition: all 0.4s ease-in-out;
}
#modal:target {
opacity: 1;
top:50%;
visibility: visible;
}
#modal .header,#modal .footer {
border-bottom: 1px solid #e7e7e7;
border-radius: 5px 5px 0 0;
}
#modal .footer {
border:none;
border-top: 1px solid #e7e7e7;
border-radius: 0 0 5px 5px;
}
#modal h2 {
margin:0;
}
#modal .btn {
float:right;
}
#modal .copy,#modal .header, #modal .footer {
padding:15px;
}
.modal-content {
background: #f7f7f7;
position: relative;
z-index: 20;
border-radius:5px;
}
#modal .copy {
background: #fff;
}
#modal .overlay {
background-color: #000;
background: rgba(0,0,0,.5);
height: 100%;
left: 0;
position: fixed;
top: 0;
width: 100%;
z-index: 10;
}
Can you guys help me figure this out?
Thank you so much
/Jonas

Related

how to prevent popup to disappear in css?

I have a popup in which I made a toggle with the help of pure CSS. Now if I run The popup and move my mouse at the uppermost or the lowermost part of the window the popup start disappear. I am using 0% JAVASCRIPT inside my popup code and can't find what was a reason in the code.
here is the issue:https://imgur.com/a/wHjHB7A
focus on the mouse cursor! Also, I am looking a way to open a popup at the page load without js
POPUP code:
.modalDialog {
position: fixed;
font-family: Arial, Helvetica, sans-serif;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: rgba(0, 0, 0, 0.8);
z-index: 99999;
opacity: 0;
-webkit-transition: opacity 400ms ease-in;
-moz-transition: opacity 400ms ease-in;
transition: opacity 400ms ease-in;
pointer-events: none;
}
.modalDialog:target,.modalDialog:hover {
opacity: 1;
pointer-events: auto;
}
.modalDialog>#__spookyPopup {
width: 400px;
position: relative;
margin: 10% auto;
padding: 5px 20px 13px 20px;
border-radius: 10px;
background: #fff;
background: -moz-linear-gradient(#fff, #999);
background: -webkit-linear-gradient(#fff, #fff);
background: -o-linear-gradient(#fff, #999);
}
.profile_container {
height: 160px;
width: 400px;
background: #;
display: inline-block;
}
.profile_div {
height: 120px;
width: 130px;
margin-top: 20px;
margin-left: 130px;
background: #ddd;
border: 1px solid grey;
}
.head_div {
min-height: 12px;
width: 100%;
}
.priv_cont {
height: 90px;
width: 400px;
background: #;
display: inline-block;
}
.priv_head {
height: 60px;
width: 330px;
margin-left:30px;
margin-top:15px;
background: #;
}
.clicker {
display: inline-block;
width: 100px;
height: 50px;
background-color: ;
color: #FFF;
}
.clicker:hover{border-bottom: 2px solid red ;
}
#click_styling
{
margin-top:20px;
height: 50px;
width: 197px;
text-align:center;
font-size:20px;color:#000;
line-height:50px;
text-decoration:none;
cursor:default;"
}
.clicker.hidden {
display: none;
}
.hiddendiv {
height: 0px;
background-color: green;
overflow: hidden;
transition: height 0.5s;
}
.social {
height: 160px;
width: 400px;
background: #ccc;
display: inline-block;
}
.social_link {
height: 60px;
width: 330px;
margin-left:30px;
margin-top:15px;
background: #ddd;
border: 1px solid grey;
}
.hiddendiv.nr2 {
background-color: red;
}
#showdiv1:target~div a[href="#showdiv1"],
#showdiv2:target~div a[href="#showdiv2"] {
display: none;
}
#showdiv1:target~div a[href="#hidediv1"],
#showdiv2:target~div a[href="#hidediv2"] {
display: inline-block;
}
#showdiv1:target~div .hiddendiv.nr1,
#showdiv2:target~div .hiddendiv.nr2 {
height: 150px;
}
Open Modal
<div id="__spooky_auth_popup" class="modalDialog">
<div id="__spookyPopup">
X
<div class="profile_container">
<div class="profile_div"></div>
</div>
<div class="head_div">
<p style="margin:0;padding:0;text-align:center;
font-size:25px;color:#8d8686;">
<I>Hey, please login to access your private content.</I>
</p>
</div>
<div id="showdiv1"></div>
<div id="showdiv2"></div>
<div>
SOCIAL
SOCIAL
MANUAL
MANUAL
<div class="hiddendiv nr1">
<div class="social">
<div class="social_link">
<div data-html="allow" >
<iframe id="iFrame1" style="border: 0px; display: block" height="400" class="spoooky-auth" src="https://api.spooo.ky/auth/facebook" border="0"></iframe>
</div>
<!-- End of facebook button -->
</div>
<div class="social_link">
<!-- Optional: Linkedin button starts here -->
<div data-html="allow" >
<iframe style="border: 0px; display: inline-block" class="spoooky-auth" src="https://api.spooo.ky/auth/linkedin" border="0"></iframe>
</div>
<!-- End of linkedin button -->
</div>
</div>
</div>
<div class="hiddendiv nr2">y</div>
</div>
<div class="priv_cont">
<div class="priv_head"><p style="margin:0;padding:0;text-align:center;font-size:18px;color:#000;">
<I>By continuing to the content you agree with the cookie
and privacy policies.</I> </p>
</div>
</div>
Any Idea?what was the issue?
Any input is apprecheated.
Thanks in Advance.
It appears your modalDialog box by default has an opacity of zero. Upon hovering it the opacity goes to one. Everything else is also nested in this div that upon no longer hovering the div, it all disappears.
.modalDialog {
position: fixed;
font-family: Arial, Helvetica, sans-serif;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: rgba(0, 0, 0, 0.8);
z-index: 99999;
opacity: 0;
-webkit-transition: opacity 400ms ease-in;
-moz-transition: opacity 400ms ease-in;
transition: opacity 400ms ease-in;
pointer-events: none;
}
.modalDialog:target,.modalDialog:hover {
opacity: 1;
pointer-events: auto;
}

Why is my popup window not appearing above all other html elements?

.box {
width: 40%;
margin: 0 auto;
padding: 35px;
border-radius: 20px/50px;
background-clip: padding-box;
text-align: center;
display: inline-block;
}
.button {
font-size: 1em;
padding: 10px;
color: #222;
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: 100px;
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: 40%;
position: relative;
transition: all 5s ease-in-out;
z-index: 999 !important;
}
.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%;
}
}
This is my css on a button which will trigger a popup window. However, some of the elements under(supposed to be) the popup showed up and covered the text on the popup window. I have already tried to set the z-index to 99999 but it doesn't work at all. Any idea?
Below is the html code as suggested
<div class="box">
<a class="button" href="#popup1">News</a>
</div>
<div id="popup1" class="overlay">
<div class="popup">
<h2>Upcoming event</h2>
<a class="close" href="#">×</a>
<div class="content">
Christmas is coming! The first ever Christmas tour to Australia is coming soon. We are looking forward to see you.
</div>
</div>
</div>
Edited:
I guess I need to provide more to explain. The input field below and the iframe element will covered my pop up window, not just simply appear behind the popup due to the transparent property. The background will be in a little of gray after the popup triggered, but the element will be shown in background color of white which the default color of my webpage. And the below element showed up without being covered....
<div class="container">
<div class="row">
<div class="col-lg-6">
Youtube Playlist
</div><!-- /.col-lg-6 -->
<div class="col-lg-6">
Youtube Single Video
</div>
</div>
<form class="form-horizontal" method="POST">
<div class="row">
<div class="col-lg-6">
<div class="input-group">
<span class="input-group-addon"><button title="Click to Show/Hide Content" type="button" onclick="if(document.getElementById('yttt') .style.display=='none') {document.getElementById('yttt') .style.display=''}else{document.getElementById('yttt') .style.display='none'}">Show/Hide</button></span>
<input type="text" class="form-control" id="ytlistbox"><span class="input-group-btn"><button class="btn btn-default" id="listclick">Preview</button></span>
<span class="input-group-btn"><button class="btn btn-default" id="singleclick">Confirm</button></span>
</div><!-- /input-group -->
</div><!-- /.col-lg-6 -->
<div class="col-lg-6">
<div class="input-group">
<span class="input-group-addon"><button title="Click to Show/Hide Content" type="button" onclick="if(document.getElementById('ytt') .style.display=='none') {document.getElementById('ytt') .style.display=''}else{document.getElementById('ytt') .style.display='none'}">Show/Hide</button></span>
<input type="text" class="form-control" id="ytsinglebox"><span class="input-group-btn"><button class="btn btn-default" id="singleclick">Preview</button></span>
<span class="input-group-btn"><button class="btn btn-default" id="singleclick">Confrim</button></span>
</div><!-- /input-group -->
</div><!-- /.col-lg-6 -->
</div>
</form>
<br />
<?php
$query2 = mysql_query("SELECT listurl, singleurl FROM tbluser WHERE user_Id = '$userid'");
$row2 = mysql_fetch_assoc($query4);
?>
<div id="yttt" class="col-lg-6" style="display: ;">
<iframe id="ytlist" src="https://www.youtube.com/embed/videoseries?list=<?php echo $row2['$listurl']?>&autoplay=1&loop=1" name="ytlist" width="550" height="400" frameborder="0" allowfullscreen></iframe>
</div>
<div id="ytt" class="col-lg-6" style="display: ;">
<iframe id="ytsingle" src="" name="ytsingle" width="550" height="400" frameborder="0" allowfullscreen></iframe>
</div>
</div>
I know quite a few of the advantage for using mysqli, strip_tag() and real_escape_string() function for security purpose. Please don't mention them again.
add top property 0
.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;
z-index:999;
}
May be you should give z-index to .overlay
.overlay{
position: fixed;
top: 100px;
bottom: 0;
left: 0;
right: 0;
background: rgba(0, 0, 0, 0.7);
transition: opacity 500ms;
visibility: hidden;
opacity: 0;
z-index:999;
}
or
This is happening because you have used semi transparent background-color for .overlay
background: rgba(0, 0, 0, 0.7);
If you don't want to show background element then use solid color #000 or #888 etc.
.box {
width: 40%;
margin: 0 auto;
padding: 35px;
border-radius: 20px/50px;
background-clip: padding-box;
text-align: center;
display: inline-block;
}
.button {
font-size: 1em;
padding: 10px;
color: #222;
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: 100px;
bottom: 0;
left: 0;
right: 0;
background: #888;
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: 40%;
position: relative;
transition: all 5s ease-in-out;
z-index: 999 !important;
}
.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%;
}
}
<div class="box">
<a class="button" href="#popup1">News</a>
</div>
<div id="popup1" class="overlay">
<div class="popup">
<h2>Upcoming event</h2>
<a class="close" href="#">×</a>
<div class="content">
Christmas is coming! The first ever Christmas tour to Australia is coming soon. We are looking forward to see you.
</div>
</div>
</div>
<h1><center>User profile</center></h1>
You need z-index to control divs/elements layers position.
FYI: z-index needs position property to work, like relative, absolute, fixed...

Button click to show overlay over image (only CSS)

I am trying to achieve that when you click the yellow circle with fa-icon inside that then the overlay shows over my image. Now the overlay shows below the image (green background with white text). My overlay code works, to see that, change div id="overlay" to div class="overlay".
How to make the button click show my overlay over the image (no javascript)?
/*#media screen and (max-width: 767px) {*/
.button i {
padding: 8px 13px;
display: inline-block;
-moz-border-radius: 180px;
-webkit-border-radius: 180px;
border-radius: 180px;
-moz-box-shadow: 0px 0px 2px #888;
-webkit-box-shadow: 0px 0px 2px #888;
box-shadow: 0px 0px 2px #888;
background-color: yellow;
color: red;
position: absolute;
left: 20%;
top: 20%;
}
/*}*/
.button i:hover {
color:#FFF;
background-color:#000;
}
/*#media screen and (min-width: 768px) {*/
.product-detailscar:hover .overlay {
opacity: 1;
}
/*}*/
.product-detailscar {
background-color: #E6E6E6;
text-align: center;
position: relative;
}
.intro, .userfield1car {
color:#fff;
font-weight:700;
font-size:22px;
text-align:center;
background-color:green;
}
.product-detailscar .overlay {
/*.well.carousel .overlay {*/
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
opacity: 0;
border-radius: 0;
background: blue;
color: #FFF;
text-align: left;
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;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet"/>
<div>
<a href="#" target="_blank">
<div class="product-detailscar">
<div class="image-video-linksidebar">
<img alt="#" src="http://lorempixel.com/200/200">
<div class="read-more"><i class="fa fa-file-text-o fa-3x" aria-hidden="true"></i>
</div>
</div>
<div id="overlay">
<div class="intro">
Intro description car
</div>
<div class="userfield1car">
Userfield-1-car
</div>
<div class="userfield1car">
Userfield-2-car
</div>
<div class="userfield1car">
Userfield-3-car
</div>
</div>
</div>
<!--</div>--></a>
</div>
You can add the following part to your CSS:
#overlay {
display: none;
}
#overlay:target {
display: block;
}
And then in your code change:
.product-detailscar .overlay
To:
#overlay
And change opacity to more then 0, ex. 0.5;
Note that it will only work one way, so it will only show the overlay. If you want to show/hide overlay in pure CSS, the checkbox hack is the way to go. For more info check https://css-tricks.com/the-checkbox-hack/
Updated example (no checkbox hack):
.button i {
padding: 8px 13px;
display: inline-block;
-moz-border-radius: 180px;
-webkit-border-radius: 180px;
border-radius: 180px;
-moz-box-shadow: 0px 0px 2px #888;
-webkit-box-shadow: 0px 0px 2px #888;
box-shadow: 0px 0px 2px #888;
background-color: yellow;
color: red;
position: absolute;
left: 20%;
top: 20%;
}
.button i:hover {
color:#FFF;
background-color:#000;
}
.product-detailscar:hover .overlay {
opacity: 1;
}
.product-detailscar {
background-color: #E6E6E6;
text-align: center;
position: relative;
}
.intro, .userfield1car {
color:#fff;
font-weight:700;
font-size:22px;
text-align:center;
background-color:green;
}
#overlay {
display: none;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
opacity: 0.5;
border-radius: 0;
background: blue;
color: #FFF;
text-align: left;
border-top: 1px solid #A10000;
border-bottom: 1px solid #A10000;
-webkit-transition: opacity 500ms;
-moz-transition: opacity 500ms;
-o-transition: opacity 500ms;
transition: opacity 500ms;
}
#overlay:target {
display: block;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet"/>
<div>
<a href="#" target="_blank">
<div class="product-detailscar">
<div class="image-video-linksidebar">
<img alt="#" src="http://lorempixel.com/200/200">
<div class="read-more"><i class="fa fa-file-text-o fa-3x" aria-hidden="true"></i>
</div>
</div>
<div id="overlay">
<div class="intro">
Intro description car
</div>
<div class="userfield1car">
Userfield-1-car
</div>
<div class="userfield1car">
Userfield-2-car
</div>
<div class="userfield1car">
Userfield-3-car
</div>
</div>
</div>
<!--</div>--></a>
</div>
BTW, it is a good idea to clean up your code ;)
You can move the overlay div just beneath the image-video-linkssidebar class like this:
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet"/>
<div>
<a href="#" target="_blank">
<div class="product-detailscar">
<div class="image-video-linksidebar">
<div id="overlay">
<div class="intro">
Intro description car
</div>
<div class="userfield1car">
Userfield-1-car
</div>
<div class="userfield1car">
Userfield-2-car
</div>
<div class="userfield1car">
Userfield-3-car
</div>
</div>
<img alt="#" src="http://lorempixel.com/200/200">
<div class="read-more"><i class="fa fa-file-text-o fa-3x" aria-hidden="true"></i>
</div>
</div>
</div>
<!--</div>--></a>
</div>
Then add these styles to overlay:
position: absolute;
z-index: 9999;
margin: 0 auto;
width: 100%;

css focus property not working properly

I am using CSS transform and transition properties. When I hover the image, the button shows up as expected over the image. The problem I found now is that when I focus on the image by pressing the TAB key, the image simply disappears and only the button shows.
Html:
<div class="main">
<img src="phone.jpg" >
<div class="paragraph">This wil be centered</div>
<div class="content">
<button>Nokia 7210 Classic</button>
</div>
</div>
CSS:
.clearfix{
clear: both;
}section
{
text-align: center;
}
.main{
float:left;
width:30%;
text-align: center;
border:10px solid white;
width:306px;
height:306px;
margin : 50px auto;
box-shadow: 0px 0px 25px black;
overflow: hidden;
}
.paragraph{
-webkit-transform: translateY(-300%);
border: 5px solid grey;
background-color: grey;
opacity: 0.5;
}
.main:hover .content,
.main:focus .content{
-webkit-transform: translateY(-340px);
-webkit-transition: -webkit-transform 700ms;
}
.content{
width: 306px;
height: 306px;
background: rgba(51, 102, 255, 0.5);
}
img{
height:inherit;
width:inherit;
-webkit-transition: -webkit-transform 5000ms;
}
button{
width: 100%;
height: 50px;
margin-top: 100px;
background: black;
border: 0;
cursor: pointer;
color: white;
font: 16px tahoma;
}
button:hover{
opacity: 0.5;
}
How can I overcome this problem in a way that the same effect happens on FOCUS?

Header content get small and hide when minimized

I have been trying to make one header in HTML with the help of CSS but the problem which I am facing is that whenever I minimize (restore down) my browser, what happen is that the header line which is HOME is get hide between those link and the link which I have specified with some hover effect got little bit downwards. Is there any solution by which even if I minimize my browser as much as I can the header position must be fixed and the content of that header must look as same as it was at normal stage.
Images are as follows:
Code :
<body>
<div id='header'>
<center><h1>Home</h1></center>
</div>
<div id="footer">
</div>
<div id="nav">
<ul>
<li>spam</li>
<li>eggs</li>
<li>foo</li>
<li>bar</li>
</ul>
</div>
</body>
CSS file you can find it on FIDDLE : FIDDLE
Simply remove position:fixed from #header and #nav
JSFiddle
This will work i think:
html
<body>
<div id="menuCont">
<div id='header'>
<center><h1>Home</h1></center>
</div>
<div id="nav">
<ul>
<li>spam</li>
<li>eggs</li>
<li>foo</li>
<li>bar</li>
</ul>
</div>
</div>
<div id="footer">
</div>
</body>
css
ul
{
list-style-type:none;
margin:0;
padding:0;
overflow:hidden;
}
li
{
float:left;
width: 25%;
}
a:link,a:visited
{
display:block;
width:100%;
color:#404040;
text-align:center;
padding:4px;
text-decoration:none;
text-transform:uppercase;
}
a:hover,a:active
{
/* background-color:#E0E0E0; */
background-color: #323B50;
color: #FFFFFF;
-webkit-transition: all 500ms ease;
-moz-transition: all 500ms ease;
-ms-transition: all 500ms ease;
-o-transition: all 500ms ease;
transition: all 500ms ease;
border-radius: 1px;
}
#nav {
background:#FFFFFF;
color:#000000;
opacity:1;
-moz-box-shadow: 1px 2px 3px rgba(0,0,0,.5);
-webkit-box-shadow: 1px 2px 3px rgba(0,0,0,.5);
box-shadow: 1px 2px 3px rgba(0,0,0,.5);
font-family:'Ubuntu';
border-radius: 1px;
position: relative;
top: 8%;
width: 100%;
z-index: 100;
left: 0%;
height: 3.5%;
padding: 0%;
font-size: 75%;
}
#header
{
position: relative;
font-size: 100%;
height:8%;
color: #FFFFFF;
background: #323B50;
width: 100%;
-moz-box-shadow: 1px 2px 3px rgba(0,0,0,.5);
-webkit-box-shadow: 1px 2px 3px rgba(0,0,0,.5);
box-shadow: 1px 2px 3px rgba(0,0,0,.5);
font-family:'Ubuntu';
border-radius: 1px;
top: 0;
z-index: 100;
left:0%;
}
#footer
{
position:absolute;
width: 100%;
top:216%;
left: 0;
height:3%;
color: #FFFFFF;
background: #323B50;
width: 100%
}
#menuCont{
position: fixed;
width: 100%;
}
fiddle