CSS Animation. Hover state flashing before animation [closed] - html

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I finally have this animation matching the proto my designer came up with, except one thing, the hover state flashes right before the animation plays. Check out my CodePen: http://codepen.io/sinrise/pen/rxvjyx/
<style type="text/css">
#keyframes bounceInUp {
from, 60%, 75%, to {
-webkit-animation-timing-function: cubic-bezier(0.8, 0.6, 0.5, 1.000);
animation-timing-function: cubic-bezier(0.8, 0.6, 0.5, 1.000);
}
from {
-webkit-transform: translate3d(0, 390px, 0);
transform: translate3d(0, 390px, 0);
}
60% {
-webkit-transform: translate3d(0, -5px, 0);
transform: translate3d(0, -5px, 0);
}
75% {
-webkit-transform: translate3d(0, 1px, 0);
transform: translate3d(0, 1px, 0);
}
to {
opacity: 1;
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
}
.small-hero {
position: relative;
width: 100%;
max-height: 385px;
min-height: 385px;
overflow-y: hidden;
margin-bottom: 15px;
}
.small-hero::before {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(rgba(0,0,0,0.0), rgba(0,0,0,0.6));
content: "";
}
.small-hero h3, .small-hero p, .small-hero a {
position: absolute;
top: 0;
margin: 0 auto;
color: #fff;
z-index: 1;
text-align: center;
}
.small-hero img { width: 100%; }
.small-hero .small-hero-hover-bg {
position: absolute;
top: 390px;
left: 0;
width: 100%;
height: 100%;
background: rgba($tmi-orange, 0.8);
z-index: 2;
}
.small-hero .small-hero-hover-h3, .small-hero .small-hero-hover-p, .small-hero .small-hero-hover-a {
position: absolute;
top: 390px;
z-index: 2;
left: 0;
right: 0;
max-width: 500px;
text-shadow: 2px 2px 10px rgba(0,0,0,0.5);
}
.small-hero .small-hero-hover-a { max-width: 200px; }
.small-hero .small-hero-hover-p { font-size: 18px; }
.small-hero:hover .small-hero-hover-bg {
top: 0;
transition: top 0.4s, opacity 0.4s;
}
.small-hero:hover .small-hero-hover-h3, .small-hero:hover .small-hero-hover-p, .small-hero:hover .small-hero-hover-a {
animation: bounceInUp 0.5s 1;
}
.small-hero:hover .small-hero-hover-h3 {
top: 100px;
}
.small-hero:hover .small-hero-hover-p {
top: 150px;
animation-delay: 0.05s;
}
.small-hero:hover .small-hero-hover-a {
top: 250px;
animation-delay: 0.1s;
}
</style>
<div class="small-hero">
<img src="http://placehold.it/500x350" />
<div class="small-hero-hover-bg"></div>
<h3>Title</h3>
<h3 class="small-hero-hover-h3">Title</h3>
<p class="small-hero-hover-p">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus quis elit nec nisl imperdiet efficitur. Ut ut mauris non sapien elementum tempor.</p>
Get a Quote
</div>

http://codepen.io/anon/pen/rxvjQW
Fixed with opacity:0; on .small-hero h3, .small-hero p, .small-hero a
and animation: bounceInUp 0.5s 1 forwards; on the hovers.
forwards makes it so that your element will stay at its last frame of the animation. opacity:0;makes it so that it starts, well, with 0 opacity.
Here's some documentation on animation-fill-mode.

Related

Trigger css animation only when it tis visible into the viewport

So,here i have a text animation on my page.The problem is that the animation is triggered only when the full page is loaded!so,I have this animation on the middle of my page it is almost impossible to see that it is a animated text! NEED SOLUTION please!
HTML CODE:
<div class="animated-title" id="anime" >
<div class="text-top">
<div>
<span>So! What Are You </span>
<span>Waiting For?</span>
</div>
</div>
<div class="text-bottom">
<div>Just click And LEARN!</div>
</div>
</div>
CSS CODE:
.animated-title {
color: #222;
font-family: Roboto, Arial, sans-serif;
height: 90vmin;
left: 30%;
position: absolute;
top: 156%;
transform: translate(-50%, -50%);
width: 90vmin;
}
.animated-title > div {
height: 50%;
overflow: hidden;
position: absolute;
width: 100%;
}
.animated-title > div div {
font-size: 9vmin;
padding: 3vmin 0;
position: absolute;
}
.animated-title > div div span {
display: block;
}
.animated-title > div.text-top {
border-bottom: 1.4vmin solid rgb(13, 231, 13);
top: 0;
border-radius: 20px;
}
.animated-title > div.text-top div {
animation: showTopText 1s;
animation-delay: 7s;
animation-fill-mode: forwards;
bottom: 0;
transform: translate(0, 100%);
}
.animated-title > div.text-top div span:first-child {
color: #767676;
}
.animated-title > div.text-bottom {
bottom: 0;
}
.animated-title > div.text-bottom div {
animation: showBottomText 1s;
animation-delay: 5s;
animation-fill-mode: forwards;
top: 0;
transform: translate(0, -100%);
}
Key frames:
0% { transform: translate3d(0, 100%, 0); }
40%, 60% { transform: translate3d(0, 50%, 0); }
100% { transform: translate3d(0, 0, 0); }
}
#keyframes showBottomText {
0% { transform: translate3d(0, -100%, 0); }
100% { transform: translate3d(0, 0, 0); }
}
I think I understand what your problem is.
As long as you do not have a problem with including a library in your code, you can do it this way:
https://www.youtube.com/watch?v=XtjO-OWFyfU
By the way, there are many tutorials on internet. You just need to search.

How to create a rainbow-colored circle using HTML and CSS?

I am trying to recreate this gif using HTML and CSS, but this is where I got stuck. Here is the gif:
https://www.link-elearning.com/linkdl/coursefiles/1452/ADCSS9_assigment_animation1.gif
This is what I have done so far but I am stuck:
<!DOCTYPE html>
<html>
<head>
<style>
.circle {
padding-top: 2px;
height: 300px;
width: 300px;
margin-left: auto;
margin-right: auto;
border-radius: 50%;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
animation: scaleIn 4s infinite cubic-bezier(.36, .11, .89, .32);
background: rgb(32, 6, 146)
}
#keyframes scaleIn {
from {
transform: scale(.5, .5);
opacity: .5;
}
to {
transform: scale(2.5, 2.5);
opacity: 0;
}
}
</style>
</head>
<body style="background-color:#050210;">
<div class="circle" style="animation-delay: -2s"></div>
<div class="circle" style="animation-delay: -1s"></div>
<div class="circle" style="animation-delay: -0"></div>
</body>
</html>
One method to get the rainbow coloured outlined is to use another div that sits behind the darker inner divs. This rainbow coloured outline can be achieved by using a linear-gradient. All the CSS animations are set to infinite to allow them to run repeatedly. Here I used some CSS variables to set the sizes of the circles indicated by -- in front of the variable name. It's good to note that it might be a good idea to put this in a wrapper/container div instead of the absolute positioning I have below. The pulsing in the centre could also use some adjustments. Press the Run code snippet button below to see the results:
body {
background: rgba(6, 2, 20, 1);
}
#Blurry_Rainbow_Circle {
position: absolute;
--Circle_Diameter: 200px;
top: calc(50% - var(--Circle_Diameter)/2);
left: calc(50% - var(--Circle_Diameter)/2);
height: var(--Circle_Diameter);
width: var(--Circle_Diameter);
border-radius: calc(var(--Circle_Diameter)/2);
background: linear-gradient(139.84deg, #A692ED 14.35%, #6CECAD 45.6%, #D87EAA 82.79%);
animation: Rotate 0.8s linear infinite;
filter: blur(20px);
}
#Rainbow_Circle {
position: absolute;
--Circle_Diameter: 200px;
top: calc(50% - var(--Circle_Diameter)/2);
left: calc(50% - var(--Circle_Diameter)/2);
height: var(--Circle_Diameter);
width: var(--Circle_Diameter);
border-radius: calc(var(--Circle_Diameter)/2);
background: linear-gradient(139.84deg, #A692ED 14.35%, #6CECAD 45.6%, #D87EAA 82.79%);
animation: Rotate 0.8s linear infinite;
}
#Large_Circle {
position: absolute;
--Circle_Diameter: 175px;
top: calc(50% - var(--Circle_Diameter)/2);
left: calc(50% - var(--Circle_Diameter)/2);
height: var(--Circle_Diameter);
width: var(--Circle_Diameter);
border-radius: calc(var(--Circle_Diameter)/2);
background: rgba(6, 2, 20, 1);
}
#Medium_Circle {
position: absolute;
--Circle_Diameter: 10px;
top: calc(50% - var(--Circle_Diameter)/2);
left: calc(50% - var(--Circle_Diameter)/2);
height: var(--Circle_Diameter);
width: var(--Circle_Diameter);
border-radius: calc(var(--Circle_Diameter)/2);
background: rgba(19, 12, 49, 1);
animation: Grow 2s linear infinite;
}
#Small_Circle {
position: absolute;
--Circle_Diameter: 10px;
top: calc(50% - var(--Circle_Diameter)/2);
left: calc(50% - var(--Circle_Diameter)/2);
height: var(--Circle_Diameter);
width: var(--Circle_Diameter);
border-radius: calc(var(--Circle_Diameter)/2);
background: rgba(19, 12, 49, 1);
animation: Grow_2 2s linear infinite;
}
#keyframes Rotate {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
#keyframes Grow {
0% {
transform: scale(1);
opacity: 1;
}
50% {
transform: scale(17);
opacity: 0;
}
51% {
transform: scale(0);
opacity: 0;
}
100% {
transform: scale(0);
opacity: 0;
}
}
#keyframes Grow_2 {
0% {
transform: scale(0);
opacity: 0;
}
40% {
transform: scale(0);
opacity: 0;
}
41% {
transform: scale(1);
opacity: 1;
}
100% {
transform: scale(17);
opacity: 0;
}
}
<div id="Blurry_Rainbow_Circle"></div>
<div id="Rainbow_Circle"></div>
<div id="Large_Circle"></div>
<div id="Medium_Circle"></div>
<div id="Small_Circle"></div>
I dont know where u study.. but it is one hell of a study.... Itadakimas... Thanks for the meal... I loved working on it
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
.body {
background-color: #050210;
height: 100vh;
width: 100vw;
display: flex;
justify-content: center;
align-items: center;
position: relative;
}
.circle {
position: absolute;
height: 230px;
width: 230px;
border-radius: 50%;
background: rgb(32, 6, 146)
}
.animate {
transform: translate(-50%, -50%);
animation: scaleIn 1.9s infinite;
}
.border {
/* --b: 5px; */
/* border width*/
animation: rotate 3s infinite linear;
z-index: 0;
/* scale: 4.5; */
--b: 10px;
--c: linear-gradient(140deg, red, yellow, green);
background: transparent;
box-shadow: 5px 5px 19px #54aa00, -5px -5px 19px #ff5a00, -5px 5px 19px #f9e203, 5px -5px 19px #f9e203;
}
.border:after {
content: "";
display: inline-block;
padding-top: 100%;
}
.border:before {
content: "";
position: absolute;
z-index: -1;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: var(--c, linear-gradient(to right, #9c20aa, #fb3570));
padding: var(--b);
border-radius: 50%;
-webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
-webkit-mask-composite: destination-out;
mask-composite: exclude;
}
#keyframes scaleIn {
from {
transform: scale(.15, .15);
opacity: .5;
}
to {
transform: scale(1, 1);
opacity: 0;
}
}
#keyframes rotate {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
<div class="body">
<div class="circle border"></div>
<div class="circle animate" style="animation-delay: -0.95s"></div>
<div class="circle animate" style="animation-delay: 0s"></div>
</div>
Whew,, Corrected all mistakes... didn't choose your color though

CSS Animation rotate3d not working in Safari

I cannot get this animation to work in Safari 12 no matter what I try. I've tried vendor prefixes and all, but nothing works.
It works fine in Chrome. Anyone have any ideas?
<div class="spinners"></div>
This is the css:
#keyframes spinx {
0% {
transform: rotate3d(0, 1, 1, 360deg);
}
100% {
transform: rotate3d(0, 0, 0, 360deg);
}
}
.spinners {
display: block;
width: 100%;
height: 4rem;
overflow: hidden;
position: relative;
}
.spinners:before, .spinners:after {
content: "";
width: 4rem;
height: 4rem;
border: 3px solid red;
border-radius: 50%;
position: absolute;
top: 50%;
left: 50%;
margin: -2rem 0 0 -2rem;
display: block;
transform-origin: 50% 50% 0;
}
.spinners:before {
animation: spinx 2s infinite linear;
}
.spinners:after {
border-color: blue;
animation: spinx 4s infinite linear alternate;
}
Here's a demo:
https://codepen.io/Skinner927/pen/vVEdag
Seems like both Safari and Firefox don't recognise the change between the two key frames. To solve this you can use an intermediate keyframe:
50% {
transform: rotate3d(0, 1, 1, 180deg);
}
Demo:
#keyframes spinx {
0% {
transform: rotate3d(0, 1, 1, 360deg);
}
50% {
transform: rotate3d(0, 1, 1, 180deg);
}
100% {
transform: rotate3d(0, 0, 0, 0);
}
}
.spinners {
display: block;
width: 100%;
height: 4rem;
overflow: hidden;
position: relative;
}
.spinners:before,
.spinners:after {
content: "";
width: 4rem;
height: 4rem;
border: 3px solid red;
border-radius: 50%;
position: absolute;
top: 50%;
left: 50%;
margin: -2rem 0 0 -2rem;
display: block;
transform-origin: 50% 50% 0;
}
.spinners:before {
animation: spinx 2s infinite linear;
}
.spinners:after {
border-color: blue;
animation: spinx 4s infinite linear alternate;
}
<div class="box">
<div class="spinners"></div>
</div>

WHY my animated text are not coming on one line

The output above the button which is text inclosed in brackets the problem is its a moving word but it's not getting placed in proper position insted it's going up and down.
I have used animated button which works fine bu the text in the brackets is scrolling as per the
need. Though i've tried a lot but not geting the desired answer
.background {
background-color: darkorange;
width: 100%;
height: 100%;
position: absolute;
}
.first{
color: orange;
text-align: center;
position: fixed;
left: 0%;
right: 0%;
z-index: 9999;
margin-left: 40px;
margin-right: 20px;
margin-top: 250px;
}
<!-- for button patrs css code -->
.button {
border-radius: 4px;
background-color: #f4511e;
border: none;
color: #FFFFFF;
text-align: center;
font-size: 28px;
padding: 10px;
width: 200px;
transition: all 0.5s;
cursor: pointer;
margin: 10px;
}
.button span {
cursor: pointer;
display: inline-block;
position: relative;
transition: 0.5s;
}
.button span:after {
content: '\00bb';
position: absolute;
opacity: 0;
top: 0;
right: -20px;
transition: 0.5s;
}
.button:hover span {
padding-right: 25px;
}
.button:hover span:after {
opacity: 1;
right: 0;
}
<!-- For body parts css codes -->
.content {
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
height: 160px;
overflow: hidden;
font-family: 'Lato', sans-serif;
font-size: 35px;
line-height: 40px;
color: #ecf0f1;
}
.content__container {
font-weight: 600;
overflow: hidden;
height: 40px;
padding: 0 40px;
}
.content__container:before {
content: '[';
left: 0;
}
.content__container:after {
content: ']';
position: absolute;
right: 0;
}
.content__container:after, .content__container:before {
position: absolute;
top: 0;
color: #16a085;
font-size: 42px;
line-height: 40px;
-webkit-animation-name: opacity;
-webkit-animation-duration: 2s;
-webkit-animation-iteration-count: infinite;
animation-name: opacity;
animation-duration: 2s;
animation-iteration-count: infinite;
}
.content__container__text {
display: inline;
float: left;
margin: 0;
}
.content__container__list {
margin-top: 0;
padding-left: 110px;
text-align: left;
list-style: none;
-webkit-animation-name: change;
-webkit-animation-duration: 10s;
-webkit-animation-iteration-count: infinite;
animation-name: change;
animation-duration: 10s;
animation-iteration-count: infinite;
}
.content__container__list__item {
line-height: 40px;
margin: 0;
}
#-webkit-keyframes opacity {
0%, 100% {
opacity: 0;
}
50% {
opacity: 1;
}
}
#-webkit-keyframes change {
0%, 12.66%, 100% {
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
16.66%, 29.32% {
-webkit-transform: translate3d(0, -25%, 0);
transform: translate3d(0, -25%, 0);
}
33.32%,45.98% {
-webkit-transform: translate3d(0, -50%, 0);
transform: translate3d(0, -50%, 0);
}
49.98%,62.64% {
-webkit-transform: translate3d(0, -75%, 0);
transform: translate3d(0, -75%, 0);
}
66.64%,79.3% {
-webkit-transform: translate3d(0, -50%, 0);
transform: translate3d(0, -50%, 0);
}
83.3%,95.96% {
-webkit-transform: translate3d(0, -20%, 0);
transform: translate3d(0, -20%, 0);
}
}
#keyframes opacity {
0%, 100% {
opacity: 0;
}
50% {
opacity: 1;
}
}
#keyframes change {
0%, 12.66%, 100% {
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
16.66%, 29.32% {
-webkit-transform: translate3d(0, -25%, 0);
transform: translate3d(0, -25%, 0);
}
33.32%,45.98% {
-webkit-transform: translate3d(0, -50%, 0);
transform: translate3d(0, -50%, 0);
}
49.98%,62.64% {
-webkit-transform: translate3d(0, -60%, 0);
transform: translate3d(0, -60%, 0);
}
66.64%,79.3% {
-webkit-transform: translate3d(0, -50%, 0);
transform: translate3d(0, -40%, 0);
}
83.3%,95.96% {
-webkit-transform: translate3d(0, -25%, 0);
transform: translate3d(0, -20%, 0);
}
}
<html>
<link rel="stylesheet" href="stylesheet.css">
<div class="background"></div>
<body>
<div class="content">
<div class="content__container">
<div class="content__container">
<p class="content__container__text">
Hello
</p>
<ul class="content__container__list">
<li class="content__container__list__item">world !</li>
<li class="content__container__list__item">users !</li>
<li class="content__container__list__item">everybody !</li>
</ul>
</div>
</div>
<button class="button"><span>Login</span></button>
<button class="button"><span>Register</span></button>
</div>
</body>
</html>
<!-- end snippet -->
I think you want something like this :
.background {
background-color: darkorange;
width: 100%;
height: 100%;
position: absolute;
}
.first{
color: orange;
text-align: center;
position: fixed;
left: 0%;
right: 0%;
z-index: 9999;
margin-left: 40px;
margin-right: 20px;
margin-top: 250px;
}
<!-- for button patrs css code -->
.button {
border-radius: 4px;
background-color: #f4511e;
border: none;
color: #FFFFFF;
text-align: center;
font-size: 28px;
padding: 10px;
width: 200px;
transition: all 0.5s;
cursor: pointer;
margin: 10px;
}
.button span {
cursor: pointer;
display: inline-block;
position: relative;
transition: 0.5s;
}
.button span:after {
content: '\00bb';
position: absolute;
opacity: 0;
top: 0;
right: -20px;
transition: 0.5s;
}
.button:hover span {
padding-right: 25px;
}
.button:hover span:after {
opacity: 1;
right: 0;
}
<!-- For body parts css codes -->
.content {
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
height: 160px;
overflow: hidden;
font-family: 'Lato', sans-serif;
font-size: 35px;
line-height: 40px;
color: #ecf0f1;
}
.content__container {
font-weight: 600;
overflow: hidden;
height: 40px;
padding: 0 40px;
}
.content__container:before {
content: '[';
left: 0;
}
.content__container:after {
content: ']';
position: absolute;
right: 0;
}
.content__container:after, .content__container:before {
position: absolute;
top: 0;
color: #16a085;
font-size: 42px;
line-height: 40px;
-webkit-animation-name: opacity;
-webkit-animation-duration: 2s;
-webkit-animation-iteration-count: infinite;
animation-name: opacity;
animation-duration: 2s;
animation-iteration-count: infinite;
}
.content__container__text {
display: inline;
float: left;
margin: 0;
}
.content__container__list {
margin-top: 0;
padding-left: 110px;
text-align: left;
list-style: none;
-webkit-animation-name: change;
-webkit-animation-duration: 10s;
-webkit-animation-iteration-count: infinite;
animation-name: change;
animation-duration: 10s;
animation-iteration-count: infinite;
}
.content__container__list__item {
line-height: 40px;
margin: 0;
}
#-webkit-keyframes opacity {
0%, 100% {
opacity: 0;
}
50% {
opacity: 1;
}
}
#-webkit-keyframes change {
0%,15%{
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
25%, 40% {
-webkit-transform: translate3d(0, -30%, 0);
transform: translate3d(0, -30%, 0);
}
50%,65% {
-webkit-transform: translate3d(0, -63%, 0);
transform: translate3d(0, -63%, 0);
}
75%,90% {
-webkit-transform: translate3d(0, -30%, 0);
transform: translate3d(0, -30%, 0);
}
100%{
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
}
#keyframes opacity {
0%, 100% {
opacity: 0;
}
50% {
opacity: 1;
}
}
#keyframes change {
0%,15%{
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
25%, 40% {
-webkit-transform: translate3d(0, -30%, 0);
transform: translate3d(0, -30%, 0);
}
50%,65% {
-webkit-transform: translate3d(0, -63%, 0);
transform: translate3d(0, -63%, 0);
}
75%,90% {
-webkit-transform: translate3d(0, -30%, 0);
transform: translate3d(0, -30%, 0);
}
100%{
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
}
<div class="background"></div>
<body>
<div class="content">
<div class="content__container">
<div class="content__container">
<p class="content__container__text">
Hello
</p>
<ul class="content__container__list">
<li class="content__container__list__item">world !</li>
<li class="content__container__list__item">users !</li>
<li class="content__container__list__item">everybody !</li>
</ul>
</div>
</div>
<button class="button"><span>Login</span></button>
<button class="button"><span>Register</span></button>
</div>

Hover state still active after mouse leaves div

I am experiencing a weird issue where the hover state is still being hovered after the mouse leaves the div. To see this hover over the picture. I tried inspecting but I can't figure it out.
Youtube video https://youtu.be/PX8psGOTbNM
Not working on Wordpress: http://sogomarketingagency.com/test-3/
Works fine on CodePen: http://codepen.io/CookieFresh89/pen/emLXEK
I have tried deactivating all plugins and reverting back to original theme and am still getting this problem.
The Code:
.modal {
display: block;
text-align: center;
width: 185px;
margin: 0 auto;
}
.modal-about > label {
background: #07B288;
border-radius: .3em;
color: #ffffff;
cursor: pointer;
display: inline-block;
font-weight: bold;
margin-left: 0px;
padding: 0.50em 1.0em;
-webkit-transition: all 0.55s;
transition: all 0.55s;
}
.modal-about input {
position: absolute;
left: -50px;
top: 130px;
z-index: -10;
}
#media (min-width: 43.75em) {
.modal-about input {
right: 50px;
}
}
.modal__overlay {
background: rgba(255, 255, 255, 0.9);
bottom: 0;
left: 0;
position: fixed;
right: 0;
text-align: center;
top: 0;
z-index: -800;
}
.modal__box {
padding: 1em .75em;
position: relative;
margin: 1em auto;
max-width: 500px;
width: 90%;
}
#media (min-height: 37.5em) {
.modal__box {
left: 50%;
position: absolute;
top: 50%;
-webkit-transform: translate(-50%, -80%);
-ms-transform: translate(-50%, -80%);
transform: translate(-50%, -80%);
}
}
#media (min-width: 50em) {
.modal__box {
padding: 1.75em;
}
}
.modal__box label {
background: #07B288;
border-radius: 50%;
color: white;
cursor: pointer;
display: inline-block;
height: 1.5em;
line-height: 1.5em;
position: absolute;
font-size: 30px;
right: .5em;
top: .5em;
width: 1.5em;
}
.modal__box h1 {
font-size: 50px;
margin-bottom:0px;
}
.modal__box h2 {
color: #07B288;
margin-bottom: 15px;
margin-top: 10px;
text-transform: uppercase;
}
.modal__box hr {
border: 0;
height: 1px;
background: #E8E8E8;
}
.modal__box p {
text-align: left;
}
.modal__overlay {
opacity: 0;
overflow: hidden;
-webkit-transform: scale(0.5);
-ms-transform: scale(0.5);
transform: scale(0.5);
-webkit-transition: all 0.75s cubic-bezier(0.68, -0.55, 0.265, 1.55);
transition: all 0.75s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}
input:checked ~ .modal__overlay {
opacity: 1;
-webkit-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1);
-webkit-transition: all 0.7s cubic-bezier(0.68, -0.55, 0.265, 1.55);
transition: all 0.7s cubic-bezier(0.68, -0.55, 0.265, 1.55);
z-index: 800;
}
input:focus + label {
-webkit-transform: scale(0.97);
-ms-transform: scale(0.97);
transform: scale(0.97);
}
.about-name-h1 {
margin-top: 10px;
}
.about-wrapper {
width: 185px;
height: 227px;
position: relative;
}
.about-overlay {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
padding: 40px 0px;
background: rgba(255, 255, 255, 0.75);
visibility: hidden;
opacity: 0;
text-align: center;
text-transform:uppercase;
}
.about-overlay:hover {
padding: 70px 0px;
}
.about-wrapper:hover .about-overlay {
visibility: visible;
opacity: 1;
}
.about-name, .about-overlay {
-webkit-transition: all 0.4s ease;
-moz-transition: all 0.4s ease;
-ms-transition: all 0.4s ease;
-o-transition: all 0.4s ease;
transition: all 0.4s ease;
}
.about-name {
padding: 15px 0px;
text-align: center;
border: 1px solid #e8e8e8;
border-top: 0;
font-size: 16px;
background: #ffffff;
margin:0px;
width: 183px;
cursor:pointer;
}
.about-name:hover {
background: #07B288;
color: #fff;
}
.avatar-frame {
border: 2px solid #07B288;
}
.avatar-frame, .avatar-frame img {
width: 120px;
height: 120px;
-webkit-border-radius: 60px;
margin: 0 auto;
/* Saf3+, Chrome */
border-radius: 60px;
/* Opera 10.5, IE 9 */
/*-moz-border-radius: 30px; Disabled for FF1+ */
}
<div class="about-wrapper">
<img src="http://sogomarketingagency.com/wp-content/uploads/garry-about-president.jpg" alt="polaroid" />
<div class="about-overlay">
<h3>Founder</h3>
<div class="modal-about">
<input id="modal-about" type="checkbox" name="modal-about" tabindex="1">
<label for="modal-about">View Profile</label>
<div class="modal__overlay">
<div class="modal__box">
<label for="modal-about">✖</label>
<div class="avatar-frame">
<img src="http://sogomarketingagency.com/wp-content/uploads/garry-about-me-president-circle.jpg" alt="">
</div>
<h1 class="about-name-h1">Garry Howell</h1>
<h2>Founder</h2>
<hr>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ac laoreet elit. Phasellus dignissim purus vitae urna cursus, quis congue ligula tristique. Ut nec blandit risus. Donec at orci ut justo venenatis viverra. Suspendisse in volutpat lacus. In enim est, dapibus eget ipsum sed, suscipit ultrices diam.</p>
</div>
</div>
</div>
</div>
</div>
<h4 class="about-name">Garry Howel</h4>
It seems that div.modal__overlay expands div.about-wrapper which creates a wider area to trigger :hover.
Edit: As mentioned by CBroe, descendants trigger the hover states of their ancestors. Since div.modal__overlay is position:fixed, it effectively creates a second hover area for but outside of div.about-wrapper.
I had success by adding visibility to the toggle for div.modal__overlay:
.modal__overlay {
opacity:0;
visibility:hidden;
...
}
input:checked ~ .modal__overlay {
opacity: 1;
visibility:visible;
...
}
However, I'm not sure why this helps, because elements hidden by visibility:hidden are still supposed to affect layout (i.e. take up space). So, if it creates a bigger :hover area with opacity:0, shouldn't it do the same with visibility:hidden? Maybe someone can help clarify this behavior.
Edit: More insight from Cbroe in the comments, below.
I built a demonstration of the difference, below. Try hovering over the blue area for box #1. Then try hovering over the same area on box #2, which is visibility:hidden.
div.container {
position:relative;
width: 200px;
height: 50px;
border: 1px solid #CCC;
margin: 0 0 1em 0;
}
div.prop {
margin-left: 200px;
width: 200px;
height: 50px;
background-color: #0CC;
}
div.prop.invisible {
visibility: hidden;
}
div.container:hover {
background-color: #F00;
}
div.container p {
position:absolute;
top:0;
left:0;
}
<div class="container">
<p>BOX #1</p>
<div class="prop"></div>
</div>
<div class="container">
<p>BOX #2</p>
<div class="prop invisible"></div>
</div>
And here is my working version of your code:
.modal {
display: block;
text-align: center;
width: 185px;
margin: 0 auto;
}
.modal-about > label {
background: #07B288;
border-radius: .3em;
color: #ffffff;
cursor: pointer;
display: inline-block;
font-weight: bold;
margin-left: 0px;
padding: 0.50em 1.0em;
-webkit-transition: all 0.55s;
transition: all 0.55s;
}
.modal-about input {
position: absolute;
left: -50px;
top: 130px;
z-index: -10;
}
#media (min-width: 43.75em) {
.modal-about input {
right: 50px;
}
}
.modal__overlay {
background: rgba(255, 255, 255, 0.9);
bottom: 0;
left: 0;
position: fixed;
right: 0;
text-align: center;
top: 0;
z-index: -800;
}
.modal__box {
padding: 1em .75em;
position: relative;
margin: 1em auto;
max-width: 500px;
width: 90%;
}
#media (min-height: 37.5em) {
.modal__box {
left: 50%;
position: absolute;
top: 50%;
-webkit-transform: translate(-50%, -80%);
-ms-transform: translate(-50%, -80%);
transform: translate(-50%, -80%);
}
}
#media (min-width: 50em) {
.modal__box {
padding: 1.75em;
}
}
.modal__box label {
background: #07B288;
border-radius: 50%;
color: white;
cursor: pointer;
display: inline-block;
height: 1.5em;
line-height: 1.5em;
position: absolute;
font-size: 30px;
right: .5em;
top: .5em;
width: 1.5em;
}
.modal__box h1 {
font-size: 50px;
margin-bottom:0px;
}
.modal__box h2 {
color: #07B288;
margin-bottom: 15px;
margin-top: 10px;
text-transform: uppercase;
}
.modal__box hr {
border: 0;
height: 1px;
background: #E8E8E8;
}
.modal__box p {
text-align: left;
}
.modal__overlay {
opacity:0;
visibility:hidden;
overflow: hidden;
-webkit-transform: scale(0.5);
-ms-transform: scale(0.5);
transform: scale(0.5);
-webkit-transition: all 0.75s cubic-bezier(0.68, -0.55, 0.265, 1.55);
transition: all 0.75s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}
input:checked ~ .modal__overlay {
opacity: 1;
visibility:visible;
-webkit-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1);
-webkit-transition: all 0.7s cubic-bezier(0.68, -0.55, 0.265, 1.55);
transition: all 0.7s cubic-bezier(0.68, -0.55, 0.265, 1.55);
z-index: 800;
}
input:focus + label {
-webkit-transform: scale(0.97);
-ms-transform: scale(0.97);
transform: scale(0.97);
}
.about-name-h1 {
margin-top: 10px;
}
.about-wrapper {
width: 185px;
height: 227px;
position: relative;
}
.about-overlay {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
padding: 40px 0px;
background: rgba(255, 255, 255, 0.75);
visibility: hidden;
opacity: 0;
text-align: center;
text-transform:uppercase;
}
.about-overlay:hover {
padding: 70px 0px;
}
.about-wrapper:hover .about-overlay {
visibility: visible;
opacity: 1;
}
.about-name, .about-overlay {
-webkit-transition: all 0.4s ease;
-moz-transition: all 0.4s ease;
-ms-transition: all 0.4s ease;
-o-transition: all 0.4s ease;
transition: all 0.4s ease;
}
.about-name {
padding: 15px 0px;
text-align: center;
border: 1px solid #e8e8e8;
border-top: 0;
font-size: 16px;
background: #ffffff;
margin:0px;
width: 183px;
cursor:pointer;
}
.about-name:hover {
background: #07B288;
color: #fff;
}
.avatar-frame {
border: 2px solid #07B288;
}
.avatar-frame, .avatar-frame img {
width: 120px;
height: 120px;
-webkit-border-radius: 60px;
margin: 0 auto;
/* Saf3+, Chrome */
border-radius: 60px;
/* Opera 10.5, IE 9 */
/*-moz-border-radius: 30px; Disabled for FF1+ */
}
<div class="about-wrapper">
<img src="http://sogomarketingagency.com/wp-content/uploads/garry-about-president.jpg" alt="polaroid" />
<div class="about-overlay">
<h3>Founder</h3>
<div class="modal-about">
<input id="modal-about" type="checkbox" name="modal-about" tabindex="1">
<label for="modal-about">View Profile</label>
<div class="modal__overlay">
<div class="modal__box">
<label for="modal-about">✖</label>
<div class="avatar-frame">
<img src="http://sogomarketingagency.com/wp-content/uploads/garry-about-me-president-circle.jpg" alt="">
</div>
<h1 class="about-name-h1">Garry Howell</h1>
<h2>Founder</h2>
<hr>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ac laoreet elit. Phasellus dignissim purus vitae urna cursus, quis congue ligula tristique. Ut nec blandit risus. Donec at orci ut justo venenatis viverra. Suspendisse in volutpat lacus. In enim est, dapibus eget ipsum sed, suscipit ultrices diam.</p>
</div>
</div>
</div>
</div>
</div>
<h4 class="about-name">Garry Howel</h4>