lightbox pure css. closing when clicking
click, css, jquery, lightbox
Solution
jsFiddle. Because the `.Info` div is inside your anchor it will remain clickable. Close the anchor just before the `.Info` div. make `.Info` display:none then add the css rule:
.box:target + .Info {
display: block;
}
+1 to Joel for a css only lightbox. Here is all the code in case the fiddle breaks:
HTML:
<a href="#resume">
<div class="seg1">
<p> Resume </p>
</div>
</a>
<a href="#" class="box" id="resume"></a>
<div class="Info">
<p>
<label for="login">Your name</label>
<input type="text" name="yourName" id="login" placeholder="" />
</p>
<p>
<label for="password">Email</label>
<input type="text" name="yourEmail" id="subject" placeholder="name@example.com" />
</p>
<p class="">
<button type="submit" class="">submit</button>
</p>
<p>
<label for="password">Message</label>
<input type="text" size="40" style="height:100px;" name="kommentar" class="message" id="kommentar" />
</p>
</div>
CSS:
a:link, a:visited, a:active, a:hover{color:#88d8d8;}
a{text-decoration:none;}
.box {
display: none;
position:absolute;
z-index:99;
width: 100%;
height: 100%;
text-align: center;
top: 0;
left: 0;
background: rgba(0,0,0,0.8);
}
.box:target {
outline: none;
display: block;
}
.box:target + .Info {
display: block;
}
.Info{
display:none;
height:400px;
width:400px;
position:relative;
background:#fff;
z-index:99999999;
margin-top:calc(20% - 50px);
margin-left:calc(50% - 250px);
border:2px solid #88d8d8;
}
.seg1 p:first-child{font-size:36px;padding:0;margin-left:60px;margin-top:95px;color:#88d8d8;text-transform:uppercase;}
/* the circle aka .seg1 */
/* the circle aka .seg1 */
/* the circle aka .seg1 */
/* You proably don't have to worry about the code below. */
.seg1{
-webkit-border-radius:400px;
border:1px solid #b1ebeb;
height:250px;
width:250px;
float:left;
background-color:#f1fbfb;
}
.seg1:hover{
animation-duration: 2s;
animation-name: zoomin2;
animation-fill-mode: forwards;
-webkit-animation-duration: 2s;
-webkit-animation-name: zoomin2;
-webkit-animation-fill-mode: forwards;
-webkit-transition: all 1s ease-in-out;
-moz-transition: all 1s ease-in-out;
-ms-transition: all 1s ease-in-out;
-o-transition: all 1s ease-in-out;
transition: all 1s ease-in-out;
background-image:url(http://www.clickwallpapers.com/wp-content/uploads/2014/04/Background-1.jpg);
background-position: -30px center;
background-size: cover;
}
Problem
If anyone would like to help me with this piece of code that would be great. I've created sort of a "lightbox", but the problem is that it closes whenever the user clicks anywhere. Which is not what i'm after. I want it to only close if the user clicks (outside) of the window and not on it. live demo is avaliable at http://jsfiddle.net/Bw3Ku/1/ ``` .box { display: none; position:fixed; z-index: 999999; width: 100%; height: 100%; text-align: center; top: 0; left: 0; background: rgba(0,0,0,0.8); } .box img { max-width: 90%; max-height: 80%; margin-top: 2%; position:absolute; z-index:99999; } .box:target { outline: none; display: block; } ``` Thanks in advance