JS free Button linked with a "popup"/overlay - button

I try to open a 'popup'/overlay with a javascript button. Unfortunately my button does not to open it.
Where I am making mistake? Is there a better way to do it?
It should be javascript free.
…………………………………………………………………………………………………………………
/* popup */
.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: 80%;
height: 80%;
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: 2%;
right: 4%;
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;
}
<button href="#popup4">btn1</button>
<div id="popup4" 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>

Your button alone doesn't do anything, it has to submit via a form.
<form method="get" action="#popup4">
<button>btn1</button>
</form>

Related

How to hover parent & have child respond to keyframe animation

I am trying to write code that mimics this animation as much as possible.
I have been going over keyframe animations & I think that they can be used to do what I need them to do.
I effectively want to have three things happen when the user hovers over the parent element. The first is the color
on the right side of the element will change dynamically (as in the picture & as in the example code), the
icon will animate into the picture & then the text will then animate.
I am new to programming & I am looking for some direction.
Example of finished product: https://imgur.com/a/bxV1V1B
DEMO
.wrapper {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
a {
display: block;
width: 200px;
height: 40px;
line-height: 40px;
font-size: 18px;
font-family: sans-serif;
text-decoration: none;
color: #333;
border: 2px solid #333;
letter-spacing: 2px;
text-align: center;
position: relative;
transition: all .35s;
}
a span {
position: relative;
z-index: 2;
}
a:after {
position: absolute;
content: "";
top: 0;
right: 0;
width: 0;
height: 100%;
background: green;
transition: all .35s;
}
a:hover:after {
width: 15%;
}
<div class="wrapper">
<span>Hover Me!</span>
</div>
Here you go. I made a CSS animation for you which will rotate and translate a new i that I have added into the HTML. I used font awesome for the check with the circle around it. Take a look:
.wrapper {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
a {
display: block;
width: 200px;
height: 40px;
line-height: 40px;
font-size: 18px;
font-family: sans-serif;
text-decoration: none;
color: #333;
border: 2px solid #333;
letter-spacing: 2px;
text-align: center;
position: relative;
transition: all .35s;
}
a span {
position: relative;
z-index: 2;
}
a:after {
position: absolute;
content: "";
top: 0;
right: 0;
width: 0;
height: 100%;
background: green;
transition: all .35s;
visibility: hidden;
}
a:hover:after {
width: 15%;
visibility: visible;
}
#check {
right: 2px;
top: 8px;
position: absolute;
display: none;
z-index: 3;
transition: right .35s;
}
a:hover #check {
animation:spin .35s linear;
display: block;
}
#keyframes spin {
0% {
transform: translate(25px) rotate(0deg);
}
100% {
transform: translate(0px) rotate(360deg);
}
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<div class="wrapper">
<span>Hover Me!</span><i id="check"style="font-size:22px; color:lightgrey" class="fa fa-check-circle"></i>
</div>

Z-index not rendering properly in Safari - works in all other browsers

I have a nav menu that slides into view from the right side of the screen once the hamburger icon is clicked. It works correctly in Chrome and Firefox - basically when triggered it takes up 50vw and fills the screen vertically. However in Safari it seems as if the z-index is not behaving correctly because the menu appears to be buried underneath the other elements of the page and ultimately not visible at all.
I've tried adjusting the z-index of a variety of elements to see if that was the simple fix and it has proven to be something more complicated. I have read a few forums that suggested including "-webkit-transform: translate3d(0, 0, 0);" but unfortunately that doesnt seem to work either. If you inspect the sidebarMenu element in Safari you can see that it is in the correct position, it is just not rendering correctly.
Below is a link to a codepen - I am missing some styles on this so the positioning isnt quite right but it effectively shows the general functionality that I am looking for. When opening this link in Safari you can see that the sidebarMenu does not appear to be rendering at all.
https://codepen.io/rmann20/pen/EzbeaV
sample code:
<div class="header">
<hr class="nav-rule">
<div class="nav-container">
<div class="nav-logo-container">
<img class="nav-logo" src="images/nav_logo.png">
<input type="checkbox" class="openSidebarMenu" id="openSidebarMenu">
<label for="openSidebarMenu" class="sidebarIconToggle">
<div class="spinner diagonal part-1"></div>
<div class="spinner horizontal"></div>
<div class="spinner diagonal part-2"></div>
</label>
<div id="sidebarMenu">
<ul class="sidebarMenuInner">
<li>Rooms & Suites</li>
<li>Packages</li>
<li>Eat & Drink</li>
<li>Meetings & Events</li>
<li>Weddings</li>
<li>Experiences</li>
<li>Neighborhood</li>
</ul>
<ul class="sidebarMenuInnerSecondary">
<li>ABOUT</li>
<li>HISTORY</li>
<li>GALLERY</li>
<li>PRESS</li>
<li>CONTACT</li>
<li>CAREERS</li>
</ul>
</div>
</div>
<img class="nav-tagline" src="images/nav_tagline.png">
<a class="nav-reservation-button" href="" target="_blank">RESERVE NOW</a>
</div>
<hr class="nav-rule">
</div>
.header {
display: flex!important;
flex-wrap: wrap;
margin: 0;
padding: 10px 0 10px 0;
width: 100%;
max-width: 100%;
box-shadow: none;
background-color: #f5f4f0;
position: fixed;
height: 110px!important;
overflow: hidden;
z-index: 10;
justify-content: space-between!important;
}
.nav-container {
display: flex;
height: 79px;
width: 100%;
align-items: center;
justify-content: space-between;
}
.main {
margin: 0 auto;
display: block;
height: 100%;
margin-top: 60px;
}
.mainInner{
display: table;
height: 100%;
width: 100%;
text-align: center;
}
.mainInner div{
display:table-cell;
vertical-align: middle;
font-size: 3em;
font-weight: bold;
letter-spacing: 1.25px;
}
#sidebarMenu {
min-height: 100%;
position: fixed;
right: 0;
width: 50vw;
margin-top: 42px;
transform: translateX(50vw);
transition: transform 250ms ease-in-out;
background-color: #f5f4f0;
overflow: scroll;
padding: 60px 60px 60px 60px;
z-index: 10000!important;
}
.sidebarMenuInner{
margin:8px;
padding:0;
border-top: 1px solid rgba(255, 255, 255, 0.10);
list-style: none;
}
.sidebarMenuInner li a{
color: #3d3936;
font-family: 'QuincyCF-ExtraBold', Helvetica, Arial, Sans-Serif;
font-weight: normal;
font-style: normal;
cursor: pointer;
text-decoration: none;
font-size: 3.2em;
}
.sidebarMenuInnerSecondary {
margin-top: 60px;
list-style: none;
}
.sidebarMenuInnerSecondary li {
margin-top: 14px;
margin-bottom: 14px;
}
input[type="checkbox"]:checked ~ #sidebarMenu {
transform: translateX(0);
}
input[type=checkbox] {
transition: all 0.3s;
box-sizing: border-box;
display: none;
}
.sidebarIconToggle {
transition: all 0.3s;
box-sizing: border-box;
cursor: pointer;
position: absolute;
z-index: 99;
height: 100%;
width: 100%;
top: 48px;
right: 40px;
height: 28px;
width: 28px;
}
.spinner {
transition: all 0.3s;
box-sizing: border-box;
position: absolute;
height: 3px;
width: 100%;
background-color: #3d3936;
}
.horizontal {
transition: all 0.3s;
box-sizing: border-box;
position: relative;
float: left;
margin-top: 3px;
}
.diagonal.part-1 {
position: relative;
transition: all 0.3s;
box-sizing: border-box;
float: left;
}
.diagonal.part-2 {
transition: all 0.3s;
box-sizing: border-box;
position: relative;
float: left;
margin-top: 3px;
}
input[type=checkbox]:checked ~ .sidebarIconToggle > .horizontal {
transition: all 0.3s;
box-sizing: border-box;
opacity: 0;
}
input[type=checkbox]:checked ~ .sidebarIconToggle > .diagonal.part-1 {
transition: all 0.3s;
box-sizing: border-box;
transform: rotate(135deg);
margin-top: 8px;
}
input[type=checkbox]:checked ~ .sidebarIconToggle > .diagonal.part-2 {
transition: all 0.3s;
box-sizing: border-box;
transform: rotate(-135deg);
margin-top: -9px;
}
.nav-logo-container {
width: 260px;
margin-left: 40px;
}
I dont get any errors and everything else seems to be working correctly, can't figure out why it's not showing at this point. Any help would be greatly appreciated!

how to make a custom popup container like youtube

I want make the popup windows like youtube share because its stick next to button. I tried bootstrap modal but it's popup in the middle of screen. When click youtube share button,pop up shows around button.
Does anyone know how to fix it?
HTML
<div class="box">
<a class="button" href="#popup1">share</a>
</div>
<div id="popup1" class="overlay">
<div class="popup">
<a class="close" href="#">×</a>
<div class="content">
<div class="social-fuctions">
Share to facebook
</div>
</div>
</div>
</div>
css code
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;
text-decoration: none;
cursor: pointer;
}
*/HTMLHTML
.social-fuctions{
display: flex;
}
.overlay {
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: rgba(0, 0, 0, 0.2);
/* transition: opacity 100ms;*/
visibility: hidden;
opacity: 0;
}
.overlay:target {
visibility: visible;
opacity: 1;
}
.popup {
position: absolute;
bottom: -550px;
right: 5%;
left: 15%;
padding: 15px;
background: #fff;
border-radius: 5px;
width: 30%;
position: relative;
}
.popup .close {
position: absolute;
top: 20px;
right: 30px;
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%;
}
}
Any suggestion? Thanks a lot
Set your box to position: relative and make the modal box / pop up a child of the box div. This way, the overlay will be positioned absolutely within the parameters of it's parent div.
.box {
position: relative;
}
.modal {
position: absolute;
}
Something like this:
https://jsfiddle.net/bommy8zu/5/
Moosetuin's approach is simple and effective.
But there is no need for a relative parent. And a absolute Modal.
I made two examples one is just like Youtube's ShareBox and the other will allways be centered.
How To Center:
position: absolute;
transform: translate(-50%, -50%);
left: 50%;
top: 50%;
Check it out here: https://codepen.io/Tibixx/pen/zWEpqq

CSS Popup With Button to Close

I am Using CSS for controlling and showing POPUP on my page, everything works fine, but i want Okay button to close popup instead of close it by clicking on cross button on right top corner . is there any way for doing this in css. or what can i do alternative for this.
.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;
}
.popup h2 {
margin-top: 0;
color: #333;
font-family: Tahoma, Arial, sans-serif;
}
.popup .close {
position: absolute;
top: 20px;
right: 30px;
transition: all 0.2s;
font-size: 30px;
font-weight: bold;
text-decoration: none;
color: #333;
}
.popup .close:hover {
color: #06D85F;
}
.popup .content {
max-height: 30%;
overflow: auto;
}
/*Let's make it appear when the page loads*/
.overlay:target:before {
display: none;
}
.overlay:before {
content:"";
top: 0;
left: 0;
right: 0;
bottom: 0;
display: block;
background: rgba(0, 0, 0, 0.6);
position: fixed;
z-index: 9;
}
.overlay .popup {
background: #fff;
border-radius: 5px;
width: 64%;
position: fixed;
top: 25%;
left: 18%;
padding: 25px;
margin: 70px auto;
z-index: 10;
-webkit-transition: all 0.6s ease-in-out;
-moz-transition: all 0.6s ease-in-out;
transition: all 0.6s ease-in-out;
}
.overlay:target .popup {
top: -100%;
left: -100%;
}
#media screen and (max-width: 768px){
.box{
width: 70%;
}
.overlay .popup{
width: 70%;
left: 15%;
}
}
<!--popup starts-->
<div id="popup1" class="overlay">
<div class="popup">
<h3 style="margin-bottom: 13px; text-align:center; color:red;">Your Application Id : <?php echo $appid;?></h3>
<a class="close" href="#popup1">×</a>
<div class="content">
Thank you <span style="text-transform:uppercase; font-weight:600;"><?php echo $firstname;?> <?php echo $middlename;?> <?php echo $surname;?></span> for registring for e-visa service.there is more text.
</div>
</div>
</div>
<!--popup end-->
.... or you could just use an anchor styled as a button
.popup h2 {
margin-top: 0;
color: #333;
font-family: Tahoma, Arial, sans-serif;
}
.popup .close {
display:block;
border:1px solid darkblue;
text-align:center;
background: steelblue;
color:white;
border-radius:5px;
padding:5px;
}
.popup .close:hover {
color: #06D85F;
}
.popup .content {
max-height: 30%;
overflow: auto;
}
/*Let's make it appear when the page loads*/
.overlay:target:before {
display: none;
}
.overlay:before {
content:"";
top: 0;
left: 0;
right: 0;
bottom: 0;
display: block;
background: rgba(0, 0, 0, 0.6);
position: fixed;
z-index: 9;
}
.overlay .popup {
background: #fff;
border-radius: 5px;
width: 64%;
position: fixed;
top: 0;
left: 18%;
padding: 25px;
margin: 70px auto;
z-index: 10;
-webkit-transition: all 0.6s ease-in-out;
-moz-transition: all 0.6s ease-in-out;
transition: all 0.6s ease-in-out;
}
.overlay:target .popup {
top: -100%;
left: -100%;
}
#media screen and (max-width: 768px){
.box{
width: 70%;
}
.overlay .popup{
width: 70%;
left: 15%;
}
}
<!--popup starts-->
<div id="popup1" class="overlay">
<div class="popup">
<h3 style="margin-bottom: 13px; text-align:center; color:red;">Your Application Id : <?php echo $appid;?></h3>
<div class="content">
Thank you <span style="text-transform:uppercase; font-weight:600;"><?php echo $firstname;?> <?php echo $middlename;?> <?php echo $surname;?></span> for registring for e-visa service.there is more text.
</div>
<a class="close" href="#popup1">OK</a>
</div>
</div>
<!--popup end-->

CSS circular menu <a href>

I want to add links to circularmenu found on https://jsfiddle.net/zv5dr670/4/.
<a href="http://www.google.com" target="_blank">
<li>
<input id='1' type='checkbox'>
<label for='1'>Option 1</label>
</li>
</a>
The link is displayed in browser status bar, but dooesn't react on a click. I don't work CSS in school for now, only HTML. Can you help me?
You could add a custom attribute to li element as follows
<li class='link' data-url='https://jsfiddle.net'>
<input id='c1' type='checkbox'/>
<label for='c1'>Menu 1</label>
</li>
Then with jQuery you can bind the link class' click event like this:
$('li.link').click(function(e) {
window.location=$(this).attr('data-url');
});
If you want to make outer circles just links you don't have to use input tag:
HTML
<div class='selector'>
<ul>
<li>Google</li>
<li>Google</li>
<li>Google</li>
<li>Google</li>
<li>Google</li>
<li>Google</li>
<li>Google</li>
<li>Google</li>
<li>Google</li>
</ul>
<button>Click</button>
</div>
<button class ="mycbutton">Click2</button>
CSS
html,
body { height: 100%; }
body {
margin: 0;
background: linear-gradient(#eeeeee, #cccccc);
overflow: hidden;
}
.mycbutton {
}
.selector {
position: absolute;
left: 50%;
top: 50%;
width: 140px;
height: 140px;
margin-top: -70px;
margin-left: -70px;
}
.selector,
.selector button {
font-family: 'Oswald', sans-serif;
font-weight: 300;
}
.selector button {
float:right;
position: relative;
width: 100%;
height: 100%;
padding: 10px;
background: #428bca;
border-radius: 50%;
border: 0;
color: white;
font-size: 20px;
cursor: pointer;
box-shadow: 0 3px 3px rgba(0, 0, 0, 0.1);
transition: all .1s;
}
.selector button:hover { background: #3071a9; }
.selector button:focus { outline: none; }
.selector ul {
position: absolute;
list-style: none;
padding: 0;
margin: 0;
top: -20px;
right: -20px;
bottom: -20px;
left: -20px;
}
.selector li {
position: absolute;
width: 0;
height: 100%;
margin: 0 50%;
-webkit-transform: rotate(-360deg);
transition: all 0.8s ease-in-out;
}
.selector li a {
position: absolute;
left: 50%;
bottom: 100%;
width: 0;
height: 0;
line-height: 1px;
margin-left: 0;
background: #fff;
border-radius: 50%;
text-align: center;
font-size: 1px;
overflow: hidden;
cursor: pointer;
box-shadow: none;
transition: all 0.8s ease-in-out, color 0.1s, background 0.1s;
text-decoration: none;
color: black;
}
.selector li a:hover { background: #f0f0f0; }
.selector.open li a {
width: 80px;
height: 80px;
line-height: 80px;
margin-left: -40px;
box-shadow: 0 3px 3px rgba(0, 0, 0, 0.1);
font-size: 14px;
}
JS
var nbOptions = 9;
var angleStart = -360;
// jquery rotate animation
function rotate(li,d) {
$({d:angleStart}).animate({d:d}, {
step: function(now) {
$(li)
.css({ transform: 'rotate('+now+'deg)' })
.find('a')
.css({ transform: 'rotate('+(-now)+'deg)' });
}, duration: 0
});
}
// show / hide the options
function toggleOptions(s) {
$(s).toggleClass('open');
var li = $(s).find('li');
var deg = $(s).hasClass('half') ? 180/(li.length-1) : 360/li.length;
for(var i=0; i<li.length; i++) {
var d = $(s).hasClass('half') ? (i*deg)-90 : i*deg;
$(s).hasClass('open') ? rotate(li[i],d) : rotate(li[i],angleStart);
}
}
$('.selector button').click(function(e) {
toggleOptions($(this).parent());
});
$('.mycbutton').click(function(e) {
toggleOptions($(this).parent());
});
setTimeout(function() { toggleOptions('.selector'); }, 100);
Run it on JSFiddle

Resources