I have created a button. When the user hovers over it, a small red arrow fades in beneath it.
The transition time is 400ms. When I hover over the button for less than 400ms, I would like the red arrow to complete its full transition before fading out.
This gif shows the full transition, followed by the undesired behaviour.
#import url('https://fonts.googleapis.com/css2?family=M+PLUS+1p&display=swap');
:root {
--init-bubble-padding: 0px;
--bubble-padding: 10px;
--triangle-height: 12px;
--transition-delay: 0ms;
--transition-time: 400ms;
}
* {
font-family: 'M PLUS 1p', Verdana, Geneva, Tahoma, sans-serif;
z-index: 100;
}
.popup-button-ctr {
display: inline-block;
position: relative;
outline: 0px solid red;
}
.button-ctr button {
background-color: rgba(30, 30, 30, 1);
border: none;
border-radius: 5px;
outline: 0px solid rgb(90, 90, 90);
font-weight: 900;
color: rgb(205, 205, 205);
padding: 8px 10px 8px 10px;
}
.button-ctr button:hover {
color: white;
cursor: pointer;
background-color: rgba(50, 50, 50, 1);
}
.triangle-up,
.triangle-right,
.triangle-down,
.triangle-left {
pointer-events: none;
display: relative;
position: absolute;
text-shadow: 1px 1px 10px rgba(21, 36, 63, 0.4);
z-index: 50;
color: rgba(255, 0, 0, 1);
background-color: transparent;
opacity: 0;
visibility: hidden;
transform: scale(0);
transition: var(--transition-time) ease-in-out;
transition-delay: var(--transition-delay);
transition-property: opacity, visibility, transform, top, right, bottom, left;
}
.popup-posr-up,
.popup-posr-right,
.popup-posr-down,
.popup-posr-left {
width: 0; height: 0;
z-index: 150;
position: absolute;
}
.popup-posr-down {
left: 50%;
}
.popup-button-ctr .triangle-down {
transform: rotate(0deg) translateX(-50%);
top: var(--init-bubble-padding);
}
.popup-button-ctr:hover .triangle-down {
transform: rotate(0deg) translateX(-50%);
opacity: 1;
visibility: visible;
transition: var(--transition-time) ease-in-out;
transition-delay: var(--transition-delay);
top: var(--bubble-padding);
<div class="popup-button-ctr">
<div class="button-ctr">
<button>
<div style="font-size: 30px">
Emoji Button
</div>
This button has emojis 😛 <br />
Let's ROCK 🤘 🤠🎸
</button>
</div>
<div class="popup-posr-down">
<div class="triangle-down">
â–²
</div>
</div>
</div>
Is there any way to force transitions to complete?
Many thanks - Oli
a CSS only solution by adding this code:
.popup-button-ctr:hover::before {
content:"";
position:fixed;
top:0;
left:0;
right:0;
bottom:0;
animation:h calc(var(--transition-time) + var(--transition-delay)) forwards;
}
#keyframes h {
99.9% {bottom:0;}
100% {bottom:100%}
}
This will increase the hoverable area to the whole screen to make sure you will keep the hover effect until the end of transition.
#import url('https://fonts.googleapis.com/css2?family=M+PLUS+1p&display=swap');
:root {
--init-bubble-padding: 0px;
--bubble-padding: 10px;
--triangle-height: 12px;
--transition-delay: 0ms;
--transition-time: 400ms;
}
* {
font-family: 'M PLUS 1p', Verdana, Geneva, Tahoma, sans-serif;
z-index: 100;
}
.popup-button-ctr {
display: inline-block;
position: relative;
outline: 0px solid red;
}
.button-ctr button {
background-color: rgba(30, 30, 30, 1);
border: none;
border-radius: 5px;
outline: 0px solid rgb(90, 90, 90);
font-weight: 900;
color: rgb(205, 205, 205);
padding: 8px 10px 8px 10px;
}
.button-ctr button:hover {
color: white;
cursor: pointer;
background-color: rgba(50, 50, 50, 1);
}
.triangle-up,
.triangle-right,
.triangle-down,
.triangle-left {
pointer-events: none;
display: relative;
position: absolute;
text-shadow: 1px 1px 10px rgba(21, 36, 63, 0.4);
z-index: 50;
color: rgba(255, 0, 0, 1);
background-color: transparent;
opacity: 0;
visibility: hidden;
transform: scale(0);
transition: var(--transition-time) ease-in-out;
transition-delay: var(--transition-delay);
transition-property: opacity, visibility, transform, top, right, bottom, left;
}
.popup-posr-up,
.popup-posr-right,
.popup-posr-down,
.popup-posr-left {
width: 0;
height: 0;
z-index: 150;
position: absolute;
}
.popup-posr-down {
left: 50%;
}
.popup-button-ctr .triangle-down {
transform: rotate(0deg) translateX(-50%);
top: var(--init-bubble-padding);
}
.popup-button-ctr:hover .triangle-down {
transform: rotate(0deg) translateX(-50%);
opacity: 1;
visibility: visible;
transition: var(--transition-time) ease-in-out;
transition-delay: var(--transition-delay);
top: var(--bubble-padding);
}
.popup-button-ctr:hover::before {
content:"";
position:fixed;
top:0;
left:0;
right:0;
bottom:0;
animation:h calc(var(--transition-time) + var(--transition-delay)) forwards;
}
#keyframes h {
99.9% {bottom:0;}
100% {bottom:100%}
}
<div class="popup-button-ctr">
<div class="button-ctr">
<button>
<div style="font-size: 30px">
Emoji Button
</div>
This button has emojis 😛 <br />
Let's ROCK 🤘 🤠🎸
</button>
</div>
<div class="popup-posr-down">
<div class="triangle-down">
â–²
</div>
</div>
</div>
In my solution, I propose animation by means of jquery, for event hover.
$('.popup-button-ctr').hover(function(){
$('.triangle-down').css("transform", "rotate(0deg) translateX(-50%)");
$('.triangle-down').css('opacity', '1');
$('.triangle-down').css('visibility', 'visible');
$('.triangle-down').css('transition', '400ms');
$('.triangle-down').css('transition-delay', '0s');
$('.triangle-down').css('top', '10px');
}, function() {
setTimeout(function() {
$('.triangle-down').css("transform", "rotate() translateX()");
$('.triangle-down').css('opacity', '');
$('.triangle-down').css('visibility', '');
$('.triangle-down').css('transition', '');
$('.triangle-down').css('transition-delay', '');
$('.triangle-down').css('top', '');
}, 400);
});
#import url('https://fonts.googleapis.com/css2?family=M+PLUS+1p&display=swap');
:root {
--init-bubble-padding: 0px;
--bubble-padding: 10px;
--triangle-height: 12px;
--transition-delay: 0ms;
--transition-time: 400ms;
}
* {
font-family: 'M PLUS 1p', Verdana, Geneva, Tahoma, sans-serif;
z-index: 100;
}
.popup-button-ctr {
display: inline-block;
position: relative;
outline: 0px solid red;
}
.button-ctr button {
background-color: rgba(30, 30, 30, 1);
border: none;
border-radius: 5px;
outline: 0px solid rgb(90, 90, 90);
font-weight: 900;
color: rgb(205, 205, 205);
padding: 8px 10px 8px 10px;
}
.button-ctr button:hover {
color: white;
cursor: pointer;
background-color: rgba(50, 50, 50, 1);
}
.triangle-up,
.triangle-right,
.triangle-down,
.triangle-left {
pointer-events: none;
display: relative;
position: absolute;
text-shadow: 1px 1px 10px rgba(21, 36, 63, 0.4);
z-index: 50;
color: rgba(255, 0, 0, 1);
background-color: transparent;
opacity: 0;
visibility: hidden;
transform: scale(0);
transition: var(--transition-time) ease-in-out;
transition-delay: var(--transition-delay);
transition-property: opacity, visibility, transform, top, right, bottom, left;
}
.popup-posr-up,
.popup-posr-right,
.popup-posr-down,
.popup-posr-left {
width: 0; height: 0;
z-index: 150;
position: absolute;
}
.popup-posr-down {
left: 50%;
}
.popup-button-ctr .triangle-down {
transform: rotate(0deg) translateX(-50%);
top: var(--init-bubble-padding);
}
/*.popup-button-ctr:hover .triangle-down {
transform: rotate(0deg) translateX(-50%);
opacity: 1;
visibility: visible;
transition: var(--transition-time) ease-in-out;
transition-delay: var(--transition-delay);
top: var(--bubble-padding);*/
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="popup-button-ctr">
<div class="button-ctr">
<button>
<div style="font-size: 30px">
Emoji Button
</div>
This button has emojis 😛 <br />
Let's ROCK 🤘 🤠🎸
</button>
</div>
<div class="popup-posr-down">
<div class="triangle-down">
â–²
</div>
</div>
</div>
If you are looking for a vanillajs solution without using any library like jQuery -
mouseover and mouseout eventlisteners are used to add a class .visible with the desired css to the triangle on hover and remove the same class after 400ms on removing the mouse cursor, allowing enough time for the transition.
document.querySelector('.popup-button-ctr').addEventListener("mouseover", function(){
document.querySelector('.triangle-down').classList.add("visible");
});
document.querySelector('.popup-button-ctr').addEventListener("mouseout", function(){
setTimeout(function() {
document.querySelector('.triangle-down').classList.remove("visible");
}, 400);
});
#import url('https://fonts.googleapis.com/css2?family=M+PLUS+1p&display=swap');
:root {
--init-bubble-padding: 0px;
--bubble-padding: 10px;
--triangle-height: 12px;
--transition-delay: 0ms;
--transition-time: 400ms;
}
* {
font-family: 'M PLUS 1p', Verdana, Geneva, Tahoma, sans-serif;
z-index: 100;
}
.popup-button-ctr {
display: inline-block;
position: relative;
outline: 0px solid red;
}
.button-ctr button {
background-color: rgba(30, 30, 30, 1);
border: none;
border-radius: 5px;
outline: 0px solid rgb(90, 90, 90);
font-weight: 900;
color: rgb(205, 205, 205);
padding: 8px 10px 8px 10px;
}
.button-ctr button:hover {
color: white;
cursor: pointer;
background-color: rgba(50, 50, 50, 1);
}
.triangle-up,
.triangle-right,
.triangle-down,
.triangle-left {
pointer-events: none;
display: relative;
position: absolute;
text-shadow: 1px 1px 10px rgba(21, 36, 63, 0.4);
z-index: 50;
color: rgba(255, 0, 0, 1);
background-color: transparent;
opacity: 0;
visibility: hidden;
transform: scale(0);
transition: var(--transition-time) ease-in-out;
transition-delay: var(--transition-delay);
transition-property: opacity, visibility, transform, top, right, bottom, left;
}
.popup-posr-up,
.popup-posr-right,
.popup-posr-down,
.popup-posr-left {
width: 0; height: 0;
z-index: 150;
position: absolute;
}
.popup-posr-down {
left: 50%;
}
.popup-button-ctr .triangle-down {
transform: rotate(0deg) translateX(-50%);
top: var(--init-bubble-padding);
}
.visible{
transform : rotate(0deg) translateX(-50%);
opacity : 1;
visibility : visible;
transition : 400ms;
transition-delay : 0s;
top : 10px;
}
<div class="popup-button-ctr">
<div class="button-ctr">
<button>
<div style="font-size: 30px">
Emoji Button
</div>
This button has emojis 😛 <br />
Let's ROCK 🤘 🤠🎸
</button>
</div>
<div class="popup-posr-down">
<div class="triangle-down">
â–²
</div>
</div>
</div>
Related
I am trying to create a form similar to SEND GRID
I am not sure what technology they have used. Google gave me some information on MaterialsCSS. Is it good to use?
Can any one guide me on this?
Pure CSS3 Will help you a lot !
.input {
position: relative;
z-index: 1;
display: inline-block;
margin: 1em;
max-width: 350px;
width: calc(100% - 2em);
vertical-align: top;
}
.input__field {
position: relative;
display: block;
float: right;
padding: 0.8em;
width: 60%;
border: none;
border-radius: 0;
background: #f0f0f0;
color: #aaa;
font-weight: 400;
font-family: "Avenir Next", "Helvetica Neue", Helvetica, Arial, sans-serif;
-webkit-appearance: none;
/* for box shadows to show on iOS */
}
.input__field:focus {
outline: none;
}
.input__label {
display: inline-block;
float: right;
padding: 0 1em;
width: 40%;
color: #696969;
font-weight: bold;
font-size: 70.25%;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.input__label-content {
position: relative;
display: block;
padding: 1.6em 0;
width: 100%;
}
.graphic {
position: absolute;
top: 0;
left: 0;
fill: none;
}
.icon {
color: #ddd;
font-size: 150%;
}
/* Nariko */
.input--nariko {
overflow: hidden;
padding-top: 2em;
}
.input__field--nariko {
width: 100%;
background: transparent;
opacity: 0;
padding: 0.35em;
z-index: 100;
color: #f18292;
}
.input__label--nariko {
width: 100%;
bottom: 0;
position: absolute;
pointer-events: none;
text-align: left;
color: #8E9191;
padding: 0 0.5em;
}
.input__label--nariko::before {
content: '';
position: absolute;
width: 100%;
height: 4em;
top: 100%;
left: 0;
background: #fff;
border-top: 4px solid #9B9F9F;
-webkit-transform: translate3d(0, -3px, 0);
transform: translate3d(0, -3px, 0);
-webkit-transition: -webkit-transform 0.4s;
transition: transform 0.4s;
-webkit-transition-timing-function: cubic-bezier(0.7, 0, 0.3, 1);
transition-timing-function: cubic-bezier(0.7, 0, 0.3, 1);
}
.input__label-content--nariko {
padding: 0.5em 0;
-webkit-transform-origin: 0% 100%;
transform-origin: 0% 100%;
-webkit-transition: -webkit-transform 0.4s, color 0.4s;
transition: transform 0.4s, color 0.4s;
-webkit-transition-timing-function: cubic-bezier(0.7, 0, 0.3, 1);
transition-timing-function: cubic-bezier(0.7, 0, 0.3, 1);
}
.input__field--nariko:focus,
.input--filled .input__field--nariko {
cursor: text;
opacity: 1;
-webkit-transition: opacity 0s 0.4s;
transition: opacity 0s 0.4s;
}
.input__field--nariko:focus + .input__label--nariko::before,
.input--filled .input__label--nariko::before {
-webkit-transition-delay: 0.05s;
transition-delay: 0.05s;
-webkit-transform: translate3d(0, -3.3em, 0);
transform: translate3d(0, -3.3em, 0);
}
.input__field--nariko:focus + .input__label--nariko .input__label-content--nariko,
.input--filled .input__label-content--nariko {
color: #6B6E6E;
-webkit-transform: translate3d(0, -3.3em, 0) scale3d(0.81, 0.81, 1);
transform: translate3d(0, -3.3em, 0) scale3d(0.81, 0.81, 1);
}
<section class="content bgcolor-7">
<h2>Input Custom Design</h2>
<span class="input input--nariko">
<input class="input__field input__field--nariko" type="text" id="input-20" />
<label class="input__label input__label--nariko" for="input-20">
<span class="input__label-content input__label-content--nariko">Username</span>
</label>
</span>
<span class="input input--nariko">
<input class="input__field input__field--nariko" type="text" id="input-21" />
<label class="input__label input__label--nariko" for="input-21">
<span class="input__label-content input__label-content--nariko">Website</span>
</label>
</span>
<span class="input input--nariko">
<input class="input__field input__field--nariko" type="text" id="input-22" />
<label class="input__label input__label--nariko" for="input-22">
<span class="input__label-content input__label-content--nariko">Invitation Code</span>
</label>
</span>
</section>
Just HTML5, CSS3 and Modern browser Try This & edit as you can......
How to do placeholder styling when Input Text are focus, the placeholder are still visible and the font-size become smaller. For example like this:
I only need webkit support. Does webkit support such thing?
.input {
width: 200px;
height: 35px;
outline:0;
padding:0 10px;
}
.label { position: absolute;
pointer-events: none;
left: 20px;
top: 18px;
transition: 0.2s ease all;
}
input:focus ~ .label,
input:not(:focus):valid ~ .label{
top: 10px;
bottom: 5px;
left: 20px;
font-size: 12px;
}
<div>
<input type="text" class="input" required/>
<span class="label">Company Name</span>
</div>
You need to use a label element and modify it accordingly. Try this:
function fillClass() {
if ($(this).val() != '')
$(this).parent().addClass('input--filled');
else
$(this).parent().removeClass('input--filled');
}
$(".sign-in-input").focusout(fillClass);
.sign-in-input-ctr {
width: 100%;
display: inline-block;
vertical-align: top;
margin-bottom: 25px;
position: relative;
margin-top: 50px;
}
.sign-in-input {
width: 100%;
border: 2px solid transparent;
-webkit-transition: all 0.3s;
transition: all 0.3s;
height: 38px;
background-color: #fff;
outline: none;
border: 1px solid rgba(73, 73, 73, 0.2);
border-radius: 2px;
padding-left: 10px;
}
.sign-in-input:focus,
.input--filled .sign-in-input {
background-color: transparent;
border: 1px solid #a09e9e;
}
.sign-in-label {
width: 100%;
font-size: 12px;
position: absolute;
top: -18px;
pointer-events: none;
overflow: hidden;
padding: 0 15px;
left: 0;
-webkit-transform: translate3d(0, 30px, 0);
transform: translate3d(0, 30px, 0);
-webkit-transition: -webkit-transform 0.3s;
transition: transform 0.3s;
}
.sign-in-input:focus+.sign-in-label,
.input--filled .sign-in-label {
-webkit-transform: translate3d(-15px, 0, 0);
transform: translate3d(-15px, 0, 0);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="sign-in-input-ctr">
<input class="sign-in-input" type="text" name="email">
<label class="sign-in-label" for="signin-email"><span class="input-label-content">Email</span>
</label>
</div>
//------ contact us dropdown list
$(document).ready(function(){
$( ".form-group .form-control" ).focus(function() {
$(this).parent().addClass('inputFous');
}).blur(function() {
if($.trim($(this).val()) == '')
{
$(this).parent().removeClass('inputFous');
}
});
});
I think there is no webkit support for this, please check this code which will help you:- Jsfiddle
I am trying to replicate the effect when you hover over a date with Material UI's date picker here (click on any text input to trigger the picker, then hover over a day) where the background expands outwards from the center.
I've tried to copy the CSS from here, but I've only managed to get the opposite working. See: https://jsfiddle.net/2zkofa0x/3/
My CSS:
span:hover {
color: #fff;
background: rgba(0, 151, 167, 0.5);
border-radius: 50%;
transform: scale(1);
transition: all 450ms cubic-bezier(0.23, 1, 0.32, 1) 0ms;
}
Would anyone know how I can have the coloured background spread out and fill from the center of the element (opposite of what I've got above)?
You could try like this. It puts the hover effect on a parent div so the hit target is always there.
Also, the circle needs to start off at a scale of 0 so it can expand to the full size during the transition.
HTML:
<div class='container'>
<div class='circle'>
</div>
<span>42</span>
</div>
CSS:
div.container {
position: relative;
height: 30px;
width: 30px;
}
div.container > div.circle {
position: absolute;
top: 0;
left: 0;
border-radius: 50%;
width: 30px;
height: 30px;
transform: scale(0);
transition: all 450ms ease 0ms;
}
div.container:hover > div.circle {
background: rgba(0, 151, 167, .5);
border-radius: 50%;
transform: scale(1);
transition: all 450ms cubic-bezier(0.23, 1, 0.32, 1) 0ms;
}
div.container span {
position: relative;
padding: 7px;
line-height: 30px;
}
div.container:hover span {
color: rgb(255, 255, 255);
}
https://jsfiddle.net/2zkofa0x/18/
Use box-shadow
li { position: relative; display: inline-block; padding: 10px; }
li:before {
content: '';
height: 1px;
width: 1px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
box-shadow: 0 0 0 0px #18b;
border-radius: 50%;
background: #18b;
transition: all .3s;
opacity: 0;
z-index: -1;
}
li:hover:before {
box-shadow: 0 0 0 15px #18b;
opacity: 1;
}
<ul>
<li>1</li>
<li>2</li>
</ul>
You could try something like this. You could also use jquery to get the same effect.
/* Material style */
button {
height: 200px;
width: 200px;
border: none;
cursor: pointer;
color: white;
padding: 15px;
border-radius: 360px;
font-size: 22px;
box-shadow: 2px 2px 4px rgba(0, 0, 0, .4);
background: #2196F3;
}
/* Ripple magic */
button{
position: relative;
overflow: hidden;
}
button:after {
content: '';
position: absolute;
top: 50%;
left: 50%;
width: 5px;
height: 5px;
background: rgba(255, 255, 255, .5);
opacity: 0;
border-radius: 50%;
transform: scale(1, 1) translate(-50%);
transform-origin: 50% 50%;
}
#keyframes ripple {
0% {
transform: scale(0, 0);
opacity: 1;
}
20% {
transform: scale(25, 25);
opacity: 1;
}
100% {
opacity: 0;
transform: scale(40, 40);
}
}
button:focus:not(:active)::after {
animation: ripple 1s ease-out;
}
/* On Hover */
.ripple-button1{
position:relative;
width:200px;
height:200px;
background-color:#99C;
color:#FFF;
border-radius:360px;
text-decoration:none;
text-align:center;
vertical-align:middle;
display:table-cell;
box-shadow: 2px 2px 4px rgba(0, 0, 0, .4);
}
.wave1{
position:absolute;
width:200px;
height:200px;
background-color:#FFF;
top:0;
left:0;
transform: scale(0);
opacity:0.5;
border-radius:300px;
}
.ripple-button1:hover > .wave1{
animation: ripple-in1 2s;
}
#keyframes ripple-in1 {
0% {transform: scale(0);}
20%{transform: scale(1);opacity:0.3;}
100%{transform: scale(1);opacity:0;}
}
<h3>Ripple on Click</h3>
<button>Click !</button>
<h3>Ripple on Hover</h3>
<div class="wave1"></div>Hover !
I was looking for the same. Thank you for raising. Though you have already chosen an answer, I'll share my hack which looks similar to the one on the quoted page.
div {
margin: 25px;
height: 100px;
width: 100px;
text-align: center; //Fix the element to center
}
span {
width: 50px;
height: 50px;
padding: 5px;
border-radius: 50%;
}
span:hover {
color: #fff;
background: rgba(0, 151, 167, 0.5);
padding: 15px; //Transform padding, width and height instead of border-radius
width: 20px;
height: 20px;
transform: scale(1);
transition: all 450ms cubic-bezier(0.23, 1, 0.32, 1) 1ms;
}
<div>
<span>42</span>
</div>
I have already created the modal in css, but when I try changing the transition so that it pops more like a modal instead of fading in, it doesn't work. I've tried changing the duration and the transition type but it doesn't seem to apply. Am I using the wrong transition?
See fiddle: https://jsfiddle.net/mtbh24uL/
.popup {
margin: 70px auto;
padding: 20px;
background: #fff;
border-radius: 5px;
width: 30%;
position: relative;
transition: all 5s ease-in-out;
}
My goal: to have more of a pop up effect like a real javascript modal. I basically need to create a modal like you see in the following picture. I'm not sure what the best approach is or the best plugin.
You could define a CSS animation for that and call this animation when you are clicking on the button. You can achieve this with adding the following CSS code. This is only an example to give you a rough idea of how your effect could look like. From this point you can even optimize and finetune the animation.
CSS
.overlay:target .popup{
animation: popup 0.7s;
}
#keyframes popup {
0%{
transform: scale(1);
}
50%{
transform: scale(1.4);
}
60%{
transform: scale(1.1);
}
70%{
transform: scale(1.2);
}
80%{
transform: scale(1);
}
90%{
transform: scale(1.1);
}
100%{
transform: scale(1);
}
}
body {
font-family: Arial, sans-serif;
background: url(http://www.shukatsu-note.com/wp-content/uploads/2014/12/computer-564136_1280.jpg) no-repeat;
background-size: cover;
height: 100vh;
}
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;
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: #fff;
border-radius: 5px;
width: 30%;
position: relative;
transition: all 5s ease-in-out;
}
.popup:after {
content: '';
position: absolute;
bottom: 100%;
width: 0;
height: 0;
border-style: solid;
border-width: 0 20px 20px 20px;
border-color: transparent transparent white transparent;
}
.overlay:target .popup {
animation: popup 0.7s;
}
.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%;
}
}
#keyframes popup {
0% {
transform: scale(1);
}
50% {
transform: scale(1.4);
}
60% {
transform: scale(1.1);
}
70% {
transform: scale(1.2);
}
80% {
transform: scale(1);
}
90% {
transform: scale(1.1);
}
100% {
transform: scale(1);
}
}
<h1>Popup/Modal Windows without JavaScript</h1>
<div class="box">
<a class="button" href="#popup1">Let me Pop up</a>
</div>
<div id="popup1" 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>
In answer to getting the curved arrow, you can use the :after or :before pseudo element. Something like this will achieve the desired effect:
CSS
.popup:after {
content: "";
position: absolute;
border: 0 solid transparent;
border-left: 24px solid white;
border-radius: 33px 0;
top: -18px;
left: 20px;
width: 30px;
height: 34px;
}
I've made an animation for a button and it works OK for all last versions of browsers, but I had updated Firefox from v.48 to v.49 and after it my animation was broken. Please if anyone knows what exactly happened help me
example: https://jsfiddle.net/3woa73fz/ (the line to the left that appears and disappears)
code:
HTML:
<div class="button__container">
<a href="#" class="button">
<span class="button__text">Learn More</span>
</a>
</div>
CSS:
.button {
&__container {
position: relative;
left: 0;
right: 0;
bottom: 0;
}
overflow: hidden;
display: inline-block;
position: relative;
-webkit-mask-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAA5JREFUeNpiYGBgAAgwAAAEAAGbA+oJAAAAAElFTkSuQmCC);
height: 54px;
margin: 0 auto;
padding: 15px 38px 14px 37px;
background-color: transparent;
border-radius: 200px;
color: transparent;
cursor: pointer;
&:before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #fff;
transform: translateX(-100%);
transition: transform 0.3s ease;
}
&:after {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
border: 2px solid rgba(255, 255, 255, 0.5);
border-radius: inherit;
transition: border 0.3s ease;
z-index: 1;
}
&__text {
position: relative;
font-family: sans-serif;
font-size: 16px;
font-weight: 400;
color: #fff;
transition: color 0.3s ease;
}
}
.button:hover:before {
transform: translateX(0);
}
.button:hover:after {
border-color: #fff;
}
.button:hover .button__text {
color: #24BE51;
}
}
inside ".button" try adding :
mask: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAA5JREFUeNpiYGBgAAgwAAAEAAGbA+oJAAAAAElFTkSuQmCC);
after ".-webkit-mask-image"