I have this html/css popup code. I want multiple popups in my page. But when I click on another popup, the first popup's content comes on. How can I make them to show different content ? Thank you.
html
<div id="closed"></div>
Klik untuk memunculkan Popup
<div class="popup-wrapper" id="popup">
<div class="popup-container"><!-- Konten popup, silahkan ganti sesuai kebutuhan -->
<form action="http://www.syakirurohman.net/2015/01/tutorial-membuat-popup-tanpa-javascript-jquery.html#" method="post" class="popup-form">
<h2>Conent</h2>
</div>
</form>
<!-- Konten popup sampai disini--><a class="popup-close" href="#closed">X</a>
</div>
</div>
css
a.popup-link {
padding:17px 0;
text-align: center;
margin:7% auto;
position: relative;
width: 300px;
color: #fff;
text-decoration: none;
background-color: #FFBA00;
border-radius: 3px;
box-shadow: 0 5px 0px 0px #eea900;
display: block;
}
a.popup-link:hover {
background-color: #ff9900;
box-shadow: 0 3px 0px 0px #eea900;
-webkit-transition:all 1s;
-moz-transition:all 1s;
transition:all 1s;
}
/* end link popup*//*style untuk popup */
#popup {
visibility: hidden;
opacity: 0;
margin-top: -200px;
}
#popup:target {
visibility:visible;
opacity: 1;
background-color: rgba(255,255,255,0.7);
position: fixed;
top:0;
left:0;
right:0;
bottom:0;
margin:0;
z-index: 99999999999;
-webkit-transition:all 1s;
-moz-transition:all 1s;
transition:all 1s;
}#media (min-width: 768px){
.popup-container {
width:600px;
}
}
#media (max-width: 767px){
.popup-container {
width:100%;
}
}
.popup-container {
position: relative;
margin:7% auto;
padding:30px 50px;
background-color: #333;
color:#fff;
border-radius: 3px;
}a.popup-close {
position: absolute;
top:1px;
right:3px;
background-color: #fff;
padding:7px 10px;
font-size: 20px;
text-decoration: none;
line-height: 1;
color:#333;
}/* style untuk isi popup */.popup-form {
margin:10px auto;
}
.popup-form h2 {
margin-bottom: 5px;
font-size: 37px;
text-transform: uppercase;
}
Here is full code for minimalist popups.
$('.btn').click(function(){
$('.popup').hide();
$('#' + $(this).attr('data-popup')).show();
});
.popup {
position:absolute;
top:50%;
left:50%;
transform:translate(-50%, -50%);
display:none;
background:#000;
color:#fff;
padding:5px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="popup" id="popup1">
Popup 1
</div>
<div class="popup" id="popup2">
Popup 2
</div>
<button class="btn" data-popup="popup1">Open pop 1</button>
<button class="btn" data-popup="popup2">Open pop 2</button>
Related
I'm working in a module box which redirects the user to an external website.
I've managed to create the layout and the content is displayed properly, however when I added the hover effect, the div is no longer clickable and so does not redirect to the external website.
Here is my jsfiddle
And here is my code:
<div class="module-box">
<div class="module-dummy"></div>
<div class="module-body module-pinterest">
<a href="www.google.com">
<div class="module-pinterest-title">Some text</div>
<div class="module-pinterest-description">
Some other text</div>
</a>
</div>
and my CSS:
.module-box {
display: inline-block;
position: relative;
width: 100%;}
.module-dummy {
margin-top: 100%;}
.module-body {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;}
.module-pinterest {
background-color: #7C56BE;}
.module-pinterest-title {
padding: 25px 25px 0px 25px;
color: #FFF;}
.module-pinterest-description {
padding: 25px 25px 0px 25px;
font-size: 22px;
line-height: 26px;
font-weight: bold;
color: #FFF;}
.module-pinterest:after {
content:'\A';
position:absolute;
width:100%; height:100%;
top:0; left:0;
background:rgba(0,0,0,0.2);
opacity:0;
transition: all 0.5s;
-webkit-transition: all 0.5s;}
.module-pinterest:hover:after {
opacity:1;}
Thanks!!
Add pointer-events:none; to your .module-pinterest:hover:after css code, like so:
.module-pinterest:hover:after {
opacity: 1;
pointer-events:none;
}
Here is the JSFiddle demo
if you move all your .module-pinterest styles to the anchor, then it should work:
.module-pinterest a {
display:block;
width:100%;
height:100%;
background-color: #7C56BE;
}
.module-pinterest a:after {
content:'\A';
position:absolute;
width:100%; height:100%;
top:0; left:0;
background:rgba(0,0,0,0.2);
opacity:0;
transition: all 0.5s;
-webkit-transition: all 0.5s;
}
.module-pinterest a:hover:after {
opacity:1;
}
Updated fiddle
Since you are using positioning for overlaying of color upon hover, convert your anchor to block and add position:relative and a z-index value:
.module-body a {
position: relative;
z-index: 9;
display:block;
}
Here is fiddle:
https://jsfiddle.net/kw5ybq9e/3/
Ive tried using z-index to over rule the absolute and relative positioning on the box hovers but it just doesn't work. Any body got any suggestions as to why? The links are there but to the side of the images rather than directly above.
HTML
<div id="container1">
<img src="images/blindsided1.jpg">
<div class="textbox">
<p id="title1">First Coding <br> Attempt</br></p>
<p id="text1"> This brief was my first attempt at designing a website.</p>
</div>
</div>
CSS
a:hover {
z-index: 99;
}
#container1 {
position:absolute;
float:left;
}
.textbox:hover {
opacity:1;
}
#title1 {
padding-top: 20px;
text-align:center;
color:#FFF;
font-family:"bebas";
font-size:32px;
word-spacing:2px;
letter-spacing:1px;
text-decoration:underline;
}
#text1 {
padding-top:40px;
text-align:center;
color:#FFF;
font-family:"bebas";
font-size:16px;
word-spacing:2px;
letter-spacing:1px;
}
.textbox {
width:361px;
height:362px;
position:absolute;
top:0;
left:0;
opacity:0;
border-radius:300px;
background-color: rgba(0, 0, 0, 0.75);
-webkit-transition: all 0.7s ease;
transition: all 0.7s ease;
}
You can wrap the whole hoverable div in the anchor tag, that way you can ensure that the hoverable div is clickable and that it points to the link that the image is referencing.
HTML
<div id="container1">
<a href="firstcoding.html">
<img src="http://zoarchurch.co.uk/content/pages/uploaded_images/91.png">
<div class="textbox">
<p id="title1">First Coding
<br>Attempt</br>
</p>
<p id="text1">
This brief was my first attempt at designing a website.
</p>
</div>
</a>
</div>
CSS
a:hover {
z-index: 99;
}
.textbox:hover {
opacity:1;
}
#title1 {
padding-top: 20px;
text-align:center;
color:#FFF;
font-family:"bebas";
font-size:32px;
word-spacing:2px;
letter-spacing:1px;
text-decoration:underline;
}
#text1 {
padding-top:40px;
text-align:center;
color:#FFF;
font-family:"bebas";
font-size:16px;
word-spacing:2px;
letter-spacing:1px;
}
.textbox {
width:361px;
height:362px;
position:absolute;
top:0;
left:0;
opacity:0;
border-radius:300px;
background-color: rgba(0, 0, 0, 0.75);
-webkit-transition: all 0.7s ease;
transition: all 0.7s ease;
}
The absolutely positioned child is sitting on top of the anchor link so any pointer interaction would fail.
You could use pointer-events:none on that child which would allow events to pass through but browser support it not great.
* {
margin: 0;
padding: 0;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
a,
img {
display: block;
}
#container1 {
position: relative;
border: 1px solid red;
float: left;
}
#container1:hover .textbox {
opacity: 1;
}
#title1 {
padding-top: 20px;
text-align: center;
color: #FFF;
font-family: "bebas";
font-size: 32px;
word-spacing: 2px;
letter-spacing: 1px;
text-decoration: underline;
}
#text1 {
padding-top: 40px;
text-align: center;
color: #FFF;
font-family: "bebas";
font-size: 16px;
word-spacing: 2px;
letter-spacing: 1px;
}
.textbox {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
opacity: 0;
border-radius: 50%;
background-color: rgba(0, 0, 0, 0.75);
-webkit-transition: all 0.7s ease;
transition: all 0.7s ease;
pointer-events: none;
}
<div id="container1">
<a href="firstcoding.html">
<img src="http://lorempixel.com/output/cats-h-c-361-362-10.jpg" />
</a>
<div class="textbox">
<p id="title1">First Coding
<br/>Attempt
</p>
<p id="text1">This brief was my first attempt at designing a website.</p>
</div>
You would do better to wrap the div inside the link and re-factor your code as suggested in the comments.
I am using the following tutorial http://www.alessioatzeni.com/wp-content/tutorials/html-css/CSS3-Hover-Effects/index_3.html as a hover effect for two images I have. When you hover over them though, only the magnifying glasses are linked, I would like it so after you hover the entire area is linked. Is it at all possible? I have been playing around with it but cannot get it to work. Any help would be greatly appreciated.
Here is the HTML
<div class="view third-effect">
<!-- Image goes here -->
<div class="mask"><a href="#" class="info" title="Full Image">
<span class="glyphicon glyphicon-search"></span>
</a></div>
<div class="content">
</div>
</div>
And here is the CSS
.view {
width: 300px;
height: 200px;
margin: 10px;
float: left;
border: 5px solid #fff;
overflow: hidden;
position: relative;
text-align: center;
box-shadow: 0px 0px 5px #aaa;
cursor: default;
}
.view .mask, .view .content {
width: 300px;
height: 200px;
position: absolute;
overflow: hidden;
top: 0;
left: 0;
}
.view img {
display: block;
position: relative;
}
.view a.info .glyphicon .glyphicon-search {
/* background:url(../img/link.png) center no-repeat; */
position: relative;
top: 1px;
font-family: 'Glyphicons Halflings';
font-style: normal;
font-weight: normal;
line-height: 1;
content: "\e006";
display: inline-block;
text-decoration: none;
padding:0;
text-indent:-9999px;
width:20px;
height:20px;
}
.third-effect .mask {
opacity: 0;
overflow:visible;
border:100px solid rgba(0,0,0,0.7);
box-sizing:border-box;
transition: all 0.4s ease-in-out;
}
.third-effect a.info .glyphicon .glyphicon-search {
position:relative;
top:70px; /* Center the link */
opacity: 0;
transition: opacity 0.5s 0s ease-in-out;
}
.third-effect:hover .mask {
opacity: 1;
border:100px solid rgba(0,0,0,0.7);
}
.third-effect:hover a.info {
opacity:1;
transition-delay: 0.3s;
}
This worked OK in my test:
Modified CSS:
.view a.info {
background:url(/images/link.png) center no-repeat;
/*display: inline-block;*/
text-decoration: none;
padding:0;
text-indent:-9999px;
/*width:20px;
height:20px;*/
display: block;
width: 300px;
height: 200px;
}
Also comment out the "border:100px" parts (there are two places I found):
/*border:100px solid rgba(0,0,0,0.7);*/
That's it, the full thumbnail can now be clicked, while the hover effect with mag glass remains as before.
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
Below is the html in question
By default it appears as:
Which is completely wrong, it should be on two lines and it should also look "pretty" but it looks pretty ugly at the moment.
The aim of the box is so that it looks like a "Loading" box which after time (already incorporated into my main bit of code) for it to disappear once loaded, so the only problem with this at the moment is that it looks ugly and doesn't layout correctly :(
The reason I have two div blocks inside the main div is because they're going to be different size and color text (I think)
If anyone has a completely different looking loading message/bar/popup that they think I would like to use please feel free to post.
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
.loading1 a {
position: fixed;
cursor: pointer;
left: 50%;
top: 10%;
color: white;
padding-left: 5px;
}
.loading2 a {
position: fixed;
cursor: pointer;
left: 50%;
top: 10%;
color: white;
padding-left: 5px;
}
.loading {
z-index: 999;
position: fixed;
left: 50%;
top: 10%;
width: 150px;
height: 80px;
border: 1px solid white;
-moz-border-radius: 10px;
border-radius: 10px;
background: #D8B93F;
}
#circularG{
position:relative;
width:25px;
height:25px}
.circularG{
position:absolute;
background-color:#0E4216;
width:6px;
height:6px;
-moz-border-radius:4px;
-moz-animation-name:bounce_circularG;
-moz-animation-duration:1.12s;
-moz-animation-iteration-count:infinite;
-moz-animation-direction:linear;
-webkit-border-radius:4px;
-webkit-animation-name:bounce_circularG;
-webkit-animation-duration:1.12s;
-webkit-animation-iteration-count:infinite;
-webkit-animation-direction:linear;
-o-border-radius:4px;
-o-animation-name:bounce_circularG;
-o-animation-duration:1.12s;
-o-animation-iteration-count:infinite;
-o-animation-direction:linear;
-ms-border-radius:4px;
-ms-animation-name:bounce_circularG;
-ms-animation-duration:1.12s;
-ms-animation-iteration-count:infinite;
-ms-animation-direction:linear;
}
#circularG_1{
left:0;
top:10px;
-moz-animation-delay:0.42s;
-webkit-animation-delay:0.42s;
-o-animation-delay:0.42s;
-ms-animation-delay:0.42s;
}
#circularG_2{
left:3px;
top:3px;
-moz-animation-delay:0.56s;
-webkit-animation-delay:0.56s;
-o-animation-delay:0.56s;
-ms-animation-delay:0.56s;
}
#circularG_3{
top:0;
left:10px;
-moz-animation-delay:0.7s;
-webkit-animation-delay:0.7s;
-o-animation-delay:0.7s;
-ms-animation-delay:0.7s;
}
#circularG_4{
right:3px;
top:3px;
-moz-animation-delay:0.84s;
-webkit-animation-delay:0.84s;
-o-animation-delay:0.84s;
-ms-animation-delay:0.84s;
}
#circularG_5{
right:0;
top:10px;
-moz-animation-delay:0.98s;
-webkit-animation-delay:0.98s;
-o-animation-delay:0.98s;
-ms-animation-delay:0.98s;
}
#circularG_6{
right:3px;
bottom:3px;
-moz-animation-delay:1.12s;
-webkit-animation-delay:1.12s;
-o-animation-delay:1.12s;
-ms-animation-delay:1.12s;
}
#circularG_7{
left:10px;
bottom:0;
-moz-animation-delay:1.26s;
-webkit-animation-delay:1.26s;
-o-animation-delay:1.26s;
-ms-animation-delay:1.26s;
}
#circularG_8{
left:3px;
bottom:3px;
-moz-animation-delay:1.4s;
-webkit-animation-delay:1.4s;
-o-animation-delay:1.4s;
-ms-animation-delay:1.4s;
}
#-moz-keyframes bounce_circularG{
0%{
-moz-transform:scale(1)}
100%{
-moz-transform:scale(.3)}
}
#-webkit-keyframes bounce_circularG{
0%{
-webkit-transform:scale(1)}
100%{
-webkit-transform:scale(.3)}
}
#-o-keyframes bounce_circularG{
0%{
-o-transform:scale(1)}
100%{
-o-transform:scale(.3)}
}
#-ms-keyframes bounce_circularG{
0%{
-ms-transform:scale(1)}
100%{
-ms-transform:scale(.3)}
}
</style>
</head>
<body>
<div class="loading"><div id="circularG">
<div id="circularG_1" class="circularG">
</div>
<div id="circularG_2" class="circularG">
</div>
<div id="circularG_3" class="circularG">
</div>
<div id="circularG_4" class="circularG">
</div>
<div id="circularG_5" class="circularG">
</div>
<div id="circularG_6" class="circularG">
</div>
<div id="circularG_7" class="circularG">
</div>
<div id="circularG_8" class="circularG">
</div>
</div>
<div class="loading1"><a>Loading, Please Wait...</a></div><div class="loading2"><br><a>(click to abort)</a></div></div>
</body>
</html>
Thanks
You don't need the position:fixed, top and left on anything inside the loading box. I have also made some changes to the positioning and spacing. Hope you like it!
http://jsfiddle.net/myajouri/9eZNQ/
HTML
<div class="loading">
<div id="circularG">
<div id="circularG_1" class="circularG"></div>
<div id="circularG_2" class="circularG"></div>
<div id="circularG_3" class="circularG"></div>
<div id="circularG_4" class="circularG"></div>
<div id="circularG_5" class="circularG"></div>
<div id="circularG_6" class="circularG"></div>
<div id="circularG_7" class="circularG"></div>
<div id="circularG_8" class="circularG"></div>
</div>
<div class="loadingText">
Loading, Please Wait...
(click to abort)
</div>
</div>
CSS
.loadingText {
color: white;
font-family: sans-serif;
font-size: 16px;
}
.loadingText a {
line-height: 32px;
color: inherit;
font-size: 14px;
text-decoration: none;
}
.loading {
z-index: 999;
position: fixed;
left: 50%;
top: 50%;
width: 170px;
height: 90px;
margin-left: -95px;
margin-top: -55px;
padding: 10px;
border: 1px solid white;
-moz-border-radius: 10px;
border-radius: 10px;
background: rgba(0, 0, 0, 0.75);
text-align: center;
}
#circularG {
position:relative;
width:25px;
height:25px;
margin: 5px auto 15px auto;
}
.circularG {
position:absolute;
background-color: white;
width:6px;
height:6px;
-moz-border-radius:4px;
-moz-animation-name:bounce_circularG;
-moz-animation-duration:1.12s;
-moz-animation-iteration-count:infinite;
-moz-animation-direction:linear;
-webkit-border-radius:4px;
-webkit-animation-name:bounce_circularG;
-webkit-animation-duration:1.12s;
-webkit-animation-iteration-count:infinite;
-webkit-animation-direction:linear;
-o-border-radius:4px;
-o-animation-name:bounce_circularG;
-o-animation-duration:1.12s;
-o-animation-iteration-count:infinite;
-o-animation-direction:linear;
-ms-border-radius:4px;
-ms-animation-name:bounce_circularG;
-ms-animation-duration:1.12s;
-ms-animation-iteration-count:infinite;
-ms-animation-direction:linear;
}
#circularG_1 {
left:0;
top:10px;
-moz-animation-delay:0.42s;
-webkit-animation-delay:0.42s;
-o-animation-delay:0.42s;
-ms-animation-delay:0.42s;
}
#circularG_2 {
left:3px;
top:3px;
-moz-animation-delay:0.56s;
-webkit-animation-delay:0.56s;
-o-animation-delay:0.56s;
-ms-animation-delay:0.56s;
}
#circularG_3 {
top:0;
left:10px;
-moz-animation-delay:0.7s;
-webkit-animation-delay:0.7s;
-o-animation-delay:0.7s;
-ms-animation-delay:0.7s;
}
#circularG_4 {
right:3px;
top:3px;
-moz-animation-delay:0.84s;
-webkit-animation-delay:0.84s;
-o-animation-delay:0.84s;
-ms-animation-delay:0.84s;
}
#circularG_5 {
right:0;
top:10px;
-moz-animation-delay:0.98s;
-webkit-animation-delay:0.98s;
-o-animation-delay:0.98s;
-ms-animation-delay:0.98s;
}
#circularG_6 {
right:3px;
bottom:3px;
-moz-animation-delay:1.12s;
-webkit-animation-delay:1.12s;
-o-animation-delay:1.12s;
-ms-animation-delay:1.12s;
}
#circularG_7 {
left:10px;
bottom:0;
-moz-animation-delay:1.26s;
-webkit-animation-delay:1.26s;
-o-animation-delay:1.26s;
-ms-animation-delay:1.26s;
}
#circularG_8 {
left:3px;
bottom:3px;
-moz-animation-delay:1.4s;
-webkit-animation-delay:1.4s;
-o-animation-delay:1.4s;
-ms-animation-delay:1.4s;
}
#-moz-keyframes bounce_circularG {
0% {
-moz-transform:scale(1)
}
100% {
-moz-transform:scale(.3)
}
}
#-webkit-keyframes bounce_circularG {
0% {
-webkit-transform:scale(1)
}
100% {
-webkit-transform:scale(.3)
}
}
#-o-keyframes bounce_circularG {
0% {
-o-transform:scale(1)
}
100% {
-o-transform:scale(.3)
}
}
#-ms-keyframes bounce_circularG {
0% {
-ms-transform:scale(1)
}
100% {
-ms-transform:scale(.3)
}
}
.loading1 a {
position: fixed;
cursor: pointer;
left: 50%;
top: 10%;
color: white;
padding-left: 5px;
}
.loading2 a {
position: fixed;
cursor: pointer;
left: 50%;
top: 10%;
color: white;
padding-left: 5px;
}
.loading {
z-index: 999;
position: fixed;
left: 50%;
top: 10%;
width: 150px;
height: 80px;
border: 1px solid white;
-moz-border-radius: 10px;
border-radius: 10px;
background: #D8B93F;
}
You need to take a look at your positioning. s you have all 3 of them set to fixed and left = 50% and top = 10%.
Due to this they will all sit in the same place on the page.
Have a look at W3School it explains it all in there and you can have a mess about with that :)
You have them set to fixed to left: 50%; top: 10%;
Try changing
.loading1 a {
position: fixed;
cursor: pointer;
left: 50%;
top: 10%;
color: white;
padding-left: 5px;
}
.loading2 a {
position: fixed;
cursor: pointer;
left: 50%;
top: 10%;
color: white;
padding-left: 5px;
}
To:
.loading1 a {
position: relative;
cursor: pointer;
left: 5%;
color: white;
padding-left: 5px;
}
.loading2 a {
position: relative;
cursor: pointer;
left: 5%;
color: white;
padding-left: 5px;
}
Updated fiddle here. In this fiddle I removed your <br>. It is two different divs so there is a break already.