How do you fix animation not triggering on hover? - html

I have a hover animation for a button but it doesn't seem to trigger.
Button:
<button class="submit-button">Send</button>
The css:
.submit-button {
background: transparent;
border: 3px solid #edc27b;
cursor: pointer;
float: left;
letter-spacing: 2px;
outline: none;
overflow: hidden;
padding: 25px 80px;
position: relative;
color: #edc27b;
font-family: "baron-neue-regular", "Helvetica", "Arial" !important;
text-transform: lowercase;
}
.submit-button::after {
content: '';
height: 100%;
left: 50%;
opacity: 0;
position: absolute;
top: 50%;
z-index: -1;
width: 100%;
background: #101010;
-webkit-transform: translateX(-50%) translateY(-50%) rotate(45deg);
-moz-transform: translateX(-50%) translateY(-50%) rotate(45deg);
-ms-transform: translateX(-50%) translateY(-50%) rotate(45deg);
-o-transform: translateX(-50%) translateY(-50%) rotate(45deg);
transform: translateX(-50%) translateY(-50%) rotate(45deg);
}
.submit-button:hover::after{
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-ms-transition: all 0.3s;
-o-transition: all 0.3s;
transition: all 0.3s;
opacity: 1;
}
What it's supposed to do is trigger another recktangle (the ::after pseudo class) to transition in from the middle across the button. This one is rotated 45 degrees so that the corners appear to be cut. I can't figure out what the problem might be.

Alright, thanks to Temani Afif I figured out that I never changed the movement, only the opacity
Before:
.submit-button:hover::after{
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-ms-transition: all 0.3s;
-o-transition: all 0.3s;
transition: all 0.3s;
opacity: 1;
}
After:
.submit-button:hover::after{
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-ms-transition: all 0.3s;
-o-transition: all 0.3s;
transition: all 0.3s;
-webkit-transform: translateX(-50%) translateY(-50%) rotate(45deg);
-moz-transform: translateX(-50%) translateY(-50%) rotate(45deg);
-ms-transform: translateX(-50%) translateY(-50%) rotate(45deg);
-o-transform: translateX(-50%) translateY(-50%) rotate(45deg);
transform: translateX(-50%) translateY(-50%) rotate(45deg);
opacity: 1;
}

Related

CSS3 button with animation issue on iPad

I've a burger icon, like this - when clicked it becomes a "X" using only CSS3 (website link here)
But my client are seeing something like this (only on iPad):
My question is:
1) What can be causing this?
2) How can I reproduce errors like this as I don't have an iPad and resizing the browser (developer tools) doesn't reproduce the error?
.mobile-nav {
position: fixed;
z-index: 10103;
bottom: 40%;
left: 45%;
margin-top: -230px;
pointer-events: none;
}
.mobile-nav .mobile-nav-bg {
/* this is the stretching navigation background */
position: absolute;
z-index: 10102;
top: 0;
right: 0;
width: 60px;
height: 60px;
border-radius: 30px !important;
background: #fff;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
webkit-transition: height .2s, box-shadow .2s;
-webkit-transition: height .2s, box-shadow .2s;
transition: height .2s, box-shadow .2s;
}
.mobile-nav-trigger {
position: absolute;
z-index: 10103;
top: 2px;
right: 0;
height: 60px;
width: 60px;
border-radius: 50% !important;
overflow: hidden;
white-space: nowrap;
color: transparent;
pointer-events: auto;
}
.mobile-nav-trigger span,
.mobile-nav-trigger span::after,
.mobile-nav-trigger span::before {
/* this is the hamburger icon */
position: absolute;
width: 16px;
height: 2px;
background-color: #000;
}
.mobile-nav-trigger span {
/* middle line of the hamburger icon */
webkit-transition: background-color 0.2s;
-webkit-transition: background-color 0.2s;
transition: background-color 0.2s;
left: 50%;
top: auto;
bottom: 50%;
right: auto;
webkit-transform: translateX(-50%) translateY(-50%);
-webkit-transform: translateX(-50%) translateY(-50%);
transform: translateX(-50%) translateY(-50%);
}
.mobile-nav-trigger span::after,
.mobile-nav-trigger span::before {
/* top and bottom lines of the hamburger icon */
content: '';
bottom: 0;
left: 0;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
webkit-transition: transform 0.2s;
-webkit-transition: -webkit-transform 0.2s;
transition: -webkit-transform 0.2s;
transition: transform 0.2s;
transition: transform 0.2s, -webkit-transform 0.2s;
}
.mobile-nav-trigger span::before {
webkit-transform: translateY(-6px);
-webkit-transform: translateY(-6px);
transform: translateY(-6px);
}
.mobile-nav-trigger span::after {
webkit-transform: translateY(6px);
-webkit-transform: translateY(6px);
transform: translateY(6px);
}
.nav-is-visible .mobile-nav-trigger span {
background-color: transparent; }
.nav-is-visible .mobile-nav-trigger span::before {
webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
-ms-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
transform: rotate(-45deg); }
.nav-is-visible .mobile-nav-trigger span::after {
webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg); }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="http://188.166.163.149/static/theme/global/plugins/bootstrap/js/bootstrap.min.js"></script>
<script>
$(document).ready(function() {
$('nav').click(function() {
$(this).toggleClass('nav-is-visible');
});
});
</script>
<div class="box">
<nav class="mobile-nav visible-xs visible-sm nav-is-visible"><a class="mobile-nav-trigger menu-trigger" href="#0"><span aria-hidden="true"></span></a><ul><li></li></ul><span aria-hidden="true" class="mobile-nav-bg"></span></nav>
</div>
In many cases your vendor prefixes are not correct. For example:
.mobile-nav-trigger span {
...
webkit-transition: background-color 0.2s;
-webkit-transition: background-color 0.2s;
transition: background-color 0.2s;
...
}
The first statement of these 3 is not legal in any browser I know of. The first line (no dash before "webkit") needs to be removed in all cases. The other two lines are valid; and should be present in all cases.
Although I haven't tested this definitively, it certain could be causing the issue you are experiencing.
Sign up for a free Apple Developer account, Download XCode and you can run the iOS device emulator as an iPad. That will allow you to test your potential fixes. You do need a Mac, however. But, that's the only way I know how you could do it other than buying or borrowing an iPad.

Grainy button transform in firefox

I am trying to transform a button, but it is really grainy (During the transform) in firefox.
Can someone take a look, the code is below... and the js fiddle link is attached here https://jsfiddle.net/L3f9cy7g/1/
As I said. The issue is only in firefox, and I think it has something to do with anti-aliasing. We tried switching it to a 3d transform, and adjusting the z-index to prevent the firefox browser from messing with the animation. No luck so far.
<div class="closePop">
<p></p>
</div>
body{background:black;}
.closePop {
right: -5px;
top: -5px;
height: 28px;
background-color: #f68d1e;
color: white;
border-radius: 50%;
width: 29px;
text-align: center;
border-style: solid;
border-width: 2px;
vertical-align: middle;
cursor: pointer;
transform: rotate(0deg);
transition: all .3s ease-out;
}
.closePop p {
margin: 0;
margin-top: 4px;
}
.closePop:hover p:after {
content:':(';
transition:contentArea 3s ease-out rotate .3s ease-out;
-webkit-transform: rotate(0deg);
-ms-transform: rotate(0deg);
-o-transform: rotate(0deg);
transform: translateZ(1px) rotate(0deg);
}
.closePop p:after {
content: 'X';
transition: all .3s ease-out;
-webkit-transform: rotate(90deg);
-ms-transform: rotate(90deg);
-o-transform: rotate(90deg);
transform: translateZ(1px) rotate(90deg);
}
.closePop:hover {
border-radius: 0;
-webkit-transform: rotate(90deg);
-ms-transform: rotate(90deg);
-o-transform: rotate(90deg);
transform: translateZ(1px) rotate(90deg);
}
.closePop p {
transition: contentArea .3s ease-out rotate .3s ease-out;
}
Try to add a transparent outline attribute,
outline: 1px solid transparent;

CSS 3 Rotate Animation on hover [duplicate]

This question already has answers here:
Spin or rotate an image on hover
(5 answers)
Closed 7 years ago.
I have this code to make a rotation on hover. It doesn't work at all. What's is wrong with it?
I need the complete animation of the rotation for 360ยบ
.icon-style-1 .builder-element-icon {
height: 100px;
width: 100px;
line-height: 100px;
background: blue;
line-height: 100px;
text-align: center;
margin: 0 auto;
display: block;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border-radius: 50%;
color: white;
}
.icon-style-1 .builder-element-icon:hover {
background: green;
-moz-transform: rotate(360deg);
-webkit-transform: rotate(360deg);
-o-transform: rotate(360deg);
-ms-transform: rotate(360deg);
transform: rotate(360deg);
}
<div class="icon-style-1">
<span class="builder-element-icon fa fa-camera"></span>
</div>
So here you go with transition on normal element style and rotate added on hover and External DEMO HERE
.icon-style-1 .builder-element-icon{
height: 100px;
width: 100px;
line-height: 100px;
background: blue;
line-height: 100px;
text-align: center;
margin: 0 auto;
display: block;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border-radius: 50%;
color: white;
/* Firefox */
-moz-transition: all 1s ease;
/* WebKit */
-webkit-transition: all 1s ease;
/* Opera */
-o-transition: all 1s ease;
/* Standard */
transition: all 1s ease;
}
.icon-style-1 .builder-element-icon:hover{
background: green;
/* Firefox */
-moz-transform: rotate(360deg) ;
/* WebKit */
-webkit-transform: rotate(360deg);
/* Opera */
-o-transform: rotate(360deg) ;
/* Standard */
transform: rotate(360deg) ;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<div class="icon-style-1">
<div class="builder-element-icon glyphicon glyphicon-camera">
</div>
</div>
360 degrees rotates it back to its original place. you probably wanted it to be 180deg;
if you want it animatad, you need to add a transition:
.icon-style-1 .builder-element-icon{
height: 100px;
width: 100px;
line-height: 100px;
background: blue;
line-height: 100px;
text-align: center;
margin: 0 auto;
display: block;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border-radius: 50%;
color: white;
-moz-transition: -moz-transform ease 0.6s;
-webkit-transition: -webkit-transform ease 0.6s;
-o-transition: -o-transform ease 0.6s;
-ms-transition: -ms-transform ease 0.6s;
transition: transform ease 0.6s;
}
.icon-style-1 .builder-element-icon:hover{
background: green;
-moz-transform: rotate(360deg);
-webkit-transform: rotate(360deg);
-o-transform: rotate(360deg);
-ms-transform: rotate(360deg);
transform: rotate(360deg);
}
<div class="icon-style-1">
<span class="builder-element-icon fa fa-camera">a</span>
</div>
and in case you want to animate the background color to, you could replace transition: transform ease 0.6s; withe either
transition: transform ease 0.6s, background ease 0.6s;
or
transition: all ease 0.6s;
You can use CSS3 transitions in order to achieve this result.
Just move your mouse over the label.
#rotatable {
font-size: 30px;
}
#rotatable:hover {
-moz-transform: rotate(360deg);
-webkit-transform: rotate(360deg);
-o-transform: rotate(360deg);
-ms-transform: rotate(360deg);
transform: rotate(360deg);
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-ms-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;
}
<span id="rotatable">I can rotate!</span>
You forgot to add CSS Transitions. Also, you don't need to use -moz, -ms and -o vendor prefixes now, see Can I Use:
JSFiddle
.icon-style-1 .builder-element-icon {
height: 100px;
width: 100px;
line-height: 100px;
background: blue;
text-align: center;
margin: 0 auto;
display: block;
border-radius: 50%;
color: white;
-webkit-transition: all 0.5s;
transition: all 0.5s;
}
.icon-style-1 .builder-element-icon:hover {
background: green;
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet"/>
<div class="icon-style-1">
<span class="builder-element-icon fa fa-camera"></span>
</div>

CSS hover won't work in Chrome

I'm making a 3d box so I need most elements absolutely positioned. Front side is img, side is an empty div at the moment. Third div is a caption div, over the image with opacity of 0. I made simple hover effect to change this opacity to 1, it's working fine in FF, but not in Chrome.
I've seen that there are some bugs when using hover on absolute positioned elements in Chrome, but as I've understood, those occur only on elements with z-index, maybe I'm mistaken. Anyhow, here's the box code, I could really use some help figuring this one out, as I'm not able to pinpoint the problem Chrome is having.
HTML:
<div class="image-wrap">
<div class="image">
<img src="img/unyield.jpg" class="image-front">
<div class="image-caption">
<span class="caption-content">Unyielding sense</span><br/>
<span class="caption-one">cover artwork</span><br/>
<span class="read-more">INFO</div>
<div class="image-side"></div>
</div>
</div>
CSS BOX:
.image-wrap {
position: absolute;
top: 50%;
left: 5%;
margin-top: -225px;
width: 360px;
height: 550px;
perspective: 1000px;
-ms-perspective: 1000px;
-moz-perspective: 1000px;
-webkit-perspective: 1000px;
-o-perspective: 1000px;
}
.image {
position: absolute;
width: 360px;
height: 550px;
transform-style: preserve-3d;
-ms-transform-style: preserve-3d;
-moz-transform-style: preserve-3d;
-webkit-transform-style: preserve-3d;
-o-transform-style: preserve-3d;
transform: translateZ(-130px);
-ms-transform: translateZ(-130px);
-moz-transform: translateZ(-130px);
-webkit-transform: translateZ(-130px);
-o-transform: translateZ(-130px);
transition: all 1s ease;
-ms-transition: all 1s ease;
-moz-transition: all 1s ease;
-webkit-transition: all 1s ease;
-o-transition: all 1s ease;
}
.image-front, .image-side {
position: absolute;
width: 360px;
height: 550px;
backface-visibility: hidden;
-webkit-backface-visibility: hidden;
}
.image-front {
transform: translateZ(180px);
-ms-transform: translateZ(180px);
-moz-transform: translateZ(180px);
-webkit-transform: translateZ(180px);
-o-transform: translateZ(180px);
}
.image-side {
transform: rotateY(90deg) translateZ(180px);
-ms-transform: rotateY(90deg) translateZ(180px);
-moz-transform: rotateY(90deg) translateZ(180px);
-webkit-transform: rotateY(90deg) translateZ(180px);
-o-transform: rotateY(90deg) translateZ(180px);
border: 1px solid #B8B5B5;
background-color: green;
}
And the problematic caption CSS:
.image-caption {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 30%;
opacity: 0;
background-color: black;
color: white;
text-align: center;
padding-top: 25px;
transition: all 0.3s ease;
-ms-transition: all 0.3s ease;
-moz-transition: all 0.3s ease;
-webkit-transition: all 0.3s ease;
-o-transition: all 0.3s ease;
}
.image:hover .image-caption{
opacity: 0.8;
}
this is giving problems px use deg
.image-front {
transform: translateZ(180px);
-ms-transform: translateZ(180px);
-moz-transform: translateZ(180px);
-webkit-transform: translateZ(180px);
-o-transform: translateZ(180px);
}
see
stackoverflow.com/questions/hardware-acceleration-in-css3
and css-performance-relative-to-translatez0

CSS pseudo element transform is choppy

I have a basic CSS transition where I rotate a pseudo ::after element and increase its width on hover. However the element transition is choppy and skips most of the animation halfway through.
Issue reproduced in a Code Pen.
I've tried using -webkit-backface-visibility: hidden; to solve the issue but I cant seem to stop the transition flash. Any ideas?
Transition css:
a {
position: relative;
text-decoration: none;
color: #db421c;
-webkit-box-shadow: inset 0px 4px 0px #fff;
-moz-box-shadow: inset 0px 4px 0px #fff;
-o-box-shadow: inset 0px 4px 0px #fff;
box-shadow: inset 0px 4px 0px #fff;
-webkit-transition: all 0.5s ease-in-out;
-moz-transition: all 0.5s ease-in-out;
-o-transition: all 0.5s ease-in-out;
transition: all 0.5s ease-in-out;
}
a + a {
margin-left: 20px;
}
a::after{
width: 20px;
height: 1px;
content: " ";
background: black;
position: absolute;
-webkit-transform: rotate(90deg) translate(55%, 10%);
-moz-transform: rotate(90deg) translate(55%, 10%);
-o-transform: rotate(90deg) translate(55%, 10%);
transform: rotate(90deg) translate(55%, 10%);
webkit-transition: all 0.5s ease-in-out;
-moz-transition: all 0.5s ease-in-out;
-o-transition: all 0.5s ease-in-out;
transition: all 0.5s ease-in-out;
}
a:last-child::after {
content: none;
}
a:hover {
color: black;
}
a:hover::after {
width: 100%;
height: 2px;
-webkit-transform: rotate(180deg) translate(100%, -20px);
-moz-transform: rotate(180deg) translate(100%, -20px);
-o-transform: rotate(180deg) translate(100%, -20px);
transform: rotate(180deg) translate(100%, -20px);
}
I isolated the issue to the translate transformation; I wasn't sure how exactly to fix it, although I have a feeling the solution is in the transform-origin property. The only working solution I was able to come up with was to use positioning in order to move the pseudo elements. The same rotation is being used, we are just making use of the absolute positioning in order to translate the elements. This method doesn't have any apparent issues given that the parent element is relatively positioned. This method should also work for elements with varying widths.
UPDATED EXAMPLE HERE - it achives the exact same effect without the choppiness.
Instead of translate(55%, 10%), use top: 10px/right: -22px
And instead of translate(100%, -20px), use top: 22px/right: 0px
Updated CSS
a::after {
width: 20px;
height: 1px;
content: " ";
background: black;
position: absolute;
-webkit-transform: rotate(90deg);
-moz-transform: rotate(90deg);
-o-transform: rotate(90deg);
transform: rotate(90deg);
webkit-transition: all 0.5s ease-in-out;
-moz-transition: all 0.5s ease-in-out;
-o-transition: all 0.5s ease-in-out;
transition: all 0.5s ease-in-out;
top: 10px;
right: -22px;
}
a:hover::after {
width: 100%;
height: 2px;
-webkit-transform: rotate(180deg);
-moz-transform: rotate(180deg);
-o-transform: rotate(180deg);
transform: rotate(180deg);
top: 22px;
right: 0px;
}