ive got a CSS popup box on my website targeted through an achor tag, it work perfectly fine in chrome and firefox but it wont open in safari, i think its something to do with the visibilty:hidden? any help would be great thanks heres a sample of the code :
<a href="#popup1" class="button">
</a>
<div id="popup1" class="overlay">
<div class="popup">
<h2>Main Stage</h2>
<a class="close" href="#">×</a>
<div class="content">content here</div>
</div>
</div>
CSS:
.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;
}
.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: $blue;
width: 50%;
position: relative;
transition: all 1s ease-in-out;
}
Try this model
Only HTML CSS
$("#open").on('click',function (){
$('#model').fadeIn(800);
});
$("#closebtn").on('click',function (){
$('#model').fadeOut(800);
});
#model{
background : rgba(0,0,0,0.7);
position: fixed;
left: 0;
top: 0;
width: 100%;
height: 100%;
z-index: 100;
display: none;
}
#modelmain{
background: #fff;
width: 30%;
position: relative;
top: 20%;
left: calc(50% - 15%);
padding: 15px;
border-right: 4px;
border-radius: 5px;
}
#closebtn{
background-color: red;
color: white;
width: 30px;
height: 30px;
line-height: 30px;
text-align: center;
border-radius: 50%;
position: absolute;
top: -15px;
right: -15px;
cursor: pointer;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<button id="open">Open model</button>
<div id="model">
<div id="modelmain">
<h2>Your Contain</h2>
<div id="closebtn">X</div>
</div>
</div>
Related
The goal is to create a simple and CSS-only modal window (popup), when the user clicks a link.
With no dependencies or any kind of script, and with as less code as possible.
.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;
}
.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 .close {
position: absolute;
top: 20px;
right: 30px;
transition: all 200ms;
font-size: 30px;
font-weight: bold;
text-decoration: none;
color: #333;
}
<div class="box">
<a class="button" href="#popup1">Open</a>
</div>
<div id="popup1" class="overlay">
<div class="popup">
<h2>Here i am</h2>
<a class="close" href="#">×</a>
</div>
</div>
I created this simple modal window:
.exit-intent {
opacity: 0;
visibility: hidden;
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
text-align: center;
background-color: rgba(255, 255, 255, .8);
z-index: 7;
display: flex;
flex-direction: column;
height: 100vh;
overflow-y: auto
}
.exit-intent {
position: fixed;
max-width: 500px;
border-radius: 10px;
background: rgba(255, 255, 255, 0.9);
visibility: hidden;
opacity: 0;
z-index: 1;
}
.exit-intent:target {
visibility: visible;
opacity: 1;
}
.exit-intent-close {
position: absolute;
max-width: 500px;
border-radius: 10px;
background: rgba(255, 255, 255, 0.9);
}
.exit-intent .close {
position: absolute;
right: 5px;
top: 5px;
padding: 5px;
color: #000;
font-size: 2em;
line-height: 0.6em;
font-weight: bold;
}
.exit-intent .close:hover {
color: #999;
}
.close-exit-intent {
background: rgba(0, 0, 0, 0.7);
cursor: default;
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
opacity: 0;
visibility: hidden;
}
.exit-intent:target+.close-exit-intent {
opacity: 1;
visibility: visible;
}
Link
<div id="exit-intent" class="exit-intent">
×
<h2>Window</h2>
</div>
Currently only the banner is working the text inside doesn't move with it. (I have tried overflow: hidden; but isn't work.)
.banner {
background-color: #996633;
position: absolute;
top: 0px;
left: 0px;
width: 100%;
height: 100px;
box-shadow: 0px 8px 20px 5px black;
transition: height 0.5s;
overflow: hidden;
}
.banner:hover {
height: 120px;
}
.navbar {
position: absolute;
right: 13px;
top: 17px;
font-size: 15px;
}
#about-page {
position: relative;
right: 130px;
bottom: 43px; /* Example of one of the tabs, the rest same as this */
}
<section class="banner">
<div id="tab">
<nav class="navbar">
<h2 id="about-page">About Us</h2>
</nav>
</div>
</section>
.banner {
background-color: #996633;
width: 100%;
height: 100px;
padding: 40px;
text-align: center;
color: #fff;
}
.banner:hover h2 {
transform: scale(1.5);
transition: transform 0.2s;
}
<section class="banner">
<h2>Hello World</h2>
</section>
I added display: flex; Here is my code running on codepen and basic concepts of flexbox here
Below is my HTML/CSS code in which I am trying to create a similar effect like HOME button as mentioned here - https://codepen.io/larrygeams/pen/pdchG
I made it to a single class, but my code is not working. Let me know what I am doing wrong here.
.btn-primary {
background: green;
border: none;
border-radius: 10px;
padding: 10px 20px;
color: #FFF;
}
.btn-primary:hover {
color: #FFF;
cursor: pointer;
}
.btn-primary:after {
content: "";
height: 100%;
left: 0;
top: 0;
width: 0px;
position: absolute;
transition: all 0.3s ease 0s;
-webkit-transition: all 0.3s ease 0s;
z-index: -1;
}
.btn-primary:after:hover {
background: red;
width: 100%;
height: 100%;
}
<button class="btn-primary" type="submit">
<div class="inner">Add to bag</div>
</button>
My Non Working Codepen Link - https://codepen.io/anon/pen/gBdVoj?editors=1100
hover pseudo needs to be placed before ::after
:hover::after
.btn-primary {
width: auto;
position: relative;
background: green;
border: none;
border-radius: 10px;
padding: 10px 20px;
color: #FFF;
z-index: 2;
}
.btn-primary:hover {
cursor:pointer;
}
.btn-primary::after {
content: "";
position: absolute;
height: 100%;
left: 0;
top: 0;
width: 0;
border-radius: 10px;
transition: all 0.3s ease 0s;
z-index: -1;
}
.btn-primary:hover::after {
width: 100%;
background: red;
}
<button class="btn-primary" type="submit">Add to bag</button>
I currently have a few vertical tabs that when hovered expand down toward the content within the page. As they expand down, a "content" div within the hovered tab expands out to the right away from the tab. I like the way this looks aside from the fact that I can't seem to get the "content" div to appear on top of the other tabs. I would assume that this is due to stacking order since when I reverse the order it works just fine. Can anyone help me resolve this issue? I've tried z-index, and opacity tricks to get it to work and nothing so far. I understand that z-index changes context based on position and opacity but my knowledge on this is limited. When you supply a possible solution, can you explain why it works?
Code:
.tab {
background: #0AF;
width: 50px;
height: 150px;
position: absolute;
top: -100px;
border-radius: 5px;
transition: all linear 0.2s;
}
.tab:hover {
top: -5px;
border-bottom-right-radius: 0px;
}
.content {
position: absolute;
left: 0;
width: 50px;
height: 150px;
background: #EEE;
border-radius: 5px;
transition: all linear 0.2s;
opacity: 0;
text-align: center;
color: #222;
}
.content .foot {
position: absolute;
bottom: 0;
margin-left: -50px;
margin-bottom: 5px;
}
.tab:hover > .content, .content:hover {
left: 40px;
width: 300px;
opacity: 1;
border-bottom-left-radius: 0px;
}
.about {
background: #0AF;
}
.social {
left: 80px;
background: #F05;
}
.projects {
left: 150px;
background: #0F5;
}
<div class="tab about">
<div class="content">
<span class="foot">About Me</span>
</div>
</div>
<div class="tab social">
<div class="content">
<span class="foot">Social Media</span>
</div>
</div>
<div class="tab projects">
<div class="content">
<span class="foot">Projects</span>
</div>
</div>
Thanks,
Jamie
You could give an z-index to .tab:hover. The order is given by the order of elements in the DOM so if you give a z-index you create a new stacking order referred to the nearest position relative parent. Smashing magazing has a good post in merit link
.tab {
background: #0AF;
width: 50px;
height: 150px;
position: absolute;
top: -100px;
border-radius: 5px;
transition: all linear 0.2s;
}
.tab:hover {
top: -5px;
z-index: 3;
}
.content {
position: absolute;
left: 0;
width: 50px;
height: 150px;
background: #EEE;
border-radius: 5px;
transition: all linear 0.2s;
opacity: 0;
text-align: center;
color: #222;
}
.content .foot {
position: absolute;
bottom: 0;
margin-left: -50px;
margin-bottom: 5px;
}
.tab:hover > .content, .content:hover {
left: 40px;
width: 300px;
opacity: 1;
}
.about {
background: #0AF;
}
.social {
left: 70px;
background: #F05;
}
.projects {
left: 130px;
background: #0F5;
}
<div class="tab about">
<div class="content">
<span class="foot">About Me</span>
</div>
</div>
<div class="tab social">
<div class="content">
<span class="foot">Social Media</span>
</div>
</div>
<div class="tab projects">
<div class="content">
<span class="foot">Projects</span>
</div>
</div>
Just Insert z-index:999 to .content
.tab {
background: #0AF;
width: 50px;
height: 150px;
position: absolute;
top: -100px;
border-radius: 5px;
transition: all linear 0.2s;
}
.tab:hover {
top: -5px;
border-bottom-right-radius: 0px;
}
.content {
position: absolute;
left: 0;
width: 50px;
height: 150px;
background: #EEE;
border-radius: 5px;
transition: all linear 0.2s;
opacity: 0;
text-align: center;
color: #222;
z-index: 999;
}
.content .foot {
position: absolute;
bottom: 0;
margin-left: -50px;
margin-bottom: 5px;
}
.tab:hover > .content, .content:hover {
left: 40px;
width: 300px;
opacity: 1;
border-bottom-left-radius: 0px;
}
.about {
background: #0AF;
}
.social {
left: 80px;
background: #F05;
}
.projects {
left: 150px;
background: #0F5;
}
<div class="tab about">
<div class="content">
<span class="foot">About Me</span>
</div>
</div>
<div class="tab social">
<div class="content">
<span class="foot">Social Media</span>
</div>
</div>
<div class="tab projects">
<div class="content">
<span class="foot">Projects</span>
</div>
</div>
here is my demo
<div class="item">
<span>Hover on me</span>
<div class="overlay">
<img src="https://cdn4.iconfinder.com/data/icons/ionicons/512/icon-play-128.png" class="slideInRight" alt="play-icon">
</div>
</div>
On any browser it works fine. In mozilla first when you hover it works fine as well, but second time when you hover you can't see animation on play icon.(you can open this fiddle link in mozilla and you will see the issue). How can I make it work every time not just for the first hover?
You could use transition instead of keyframes since you just have a simple animation.
.item {
position: relative;
height: 200px;
width: 300px;
border: 2px solid #000;
text-align: center;
line-height: 200px;
color: #000;
font-family: 'Arial';
margin: 25px 0px 0px 25px;
font-size: 25px;
font-weight: bold;
cursor: pointer;
}
.overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
text-align: center;
background: #fff;
display: none;
}
.overlay img {
width: 80px;
height: auto;
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
margin: auto;
}
.overlay img.slideInRight {
transition: left 0.2s ease;
left: 50%;
}
.overlay:hover img.slideInRight {
left: 0;
}
.item:hover .overlay {
display: block;
}
<div class="item">
<span>Hover on me</span>
<div class="overlay">
<img src="https://cdn4.iconfinder.com/data/icons/ionicons/512/icon-play-128.png" class="slideInRight" alt="play-icon">
</div>
</div>