I've been trying to learn css animations by making a little personal site.
Joseph.how
I wanted the title to start large and near the page center, move up, then shrink and move to the left. Unfortunately when using safari the title moves to the left but instead of staying vertically centered, rises slightly, then pops back to center after the animation is done.
You can see the intended behavior on chrome (haven't tested with other browsers yet).
EDIT The problem persists with prefixes
(used auto-prefix extension in brackets)
Link to repo: https://github.com/JoeHowarth/joehowarth.me
EDIT 2 The problem is really just with the title-over keyframe, so I isolated that one
.header-container {
width: 100%;
border-bottom: 1px #000 solid;
height: 40vh;
position: relative;
background-color: #000;
color: #eee;
-webkit-animation: banner-up 1s 2s ease-in-out forwards;
animation: banner-up 1s 2s ease-in-out forwards;
font-family: 'Lato';
.title {
font-size: 30px;
position: absolute;
top: 90%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
font-weight: 700;
letter-spacing: .5em;
font-size: 60px;
-webkit-animation: title-over 4s 2s ease-in-out forwards;
animation: title-over 4s 2s ease-in-out forwards;
span {
font-weight: 100;
letter-spacing: .1em;
font-style: italic;
}
}
nav {
width: 40vw;
height: 10%;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
-webkit-box-pack: justify;
-ms-flex-pack: justify;
justify-content: space-between;
-webkit-box-orient: horizontal;
-webkit-box-direction: normal;
-ms-flex-direction: row;
flex-direction: row;
position: absolute;
top: -5vw;
right: 20px;
-webkit-transform: translate(0, -50%);
transform: translate(0, -50%);
-webkit-animation: nav 1s 7s ease-out forwards;
animation: nav 1s 7s ease-out forwards;
-webkit-transition : all 2s ease;
transition: all 2s ease;
div {
width: 15vw;
height: 100%;
margin: 0 2px;
// border: 1px #333 solid;
background: #111;
&:hover {
background: #222;
}
&:active {
background: #2a2a2a;
font-size: 38px;
}
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
font-size: 35px;
p {
text-align: center;
color: #eee;
display: block;
font-weight: 100;
}
}
}
}
// move title to left, make smaller
#keyframes title-over {
30% {
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
45% {
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
letter-spacing: .5em;
font-size: 60px;
}
65% {
letter-spacing: .5em;
}
100% {
top: 50%;
left: 10px;
-webkit-transform: translate(0%, -50%);
transform: translate(0%, -50%);
letter-spacing: .1em;
font-size: 40px;
}
}
#-webkit-keyframes title-over {
30% {
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
45% {
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
letter-spacing: .5em;
font-size: 60px;
}
65% {
letter-spacing: .5em;
}
100% {
top: 50%;
left: 10px;
-webkit-transform: translate(0%, -50%);
transform: translate(0%, -50%);
letter-spacing: .1em;
font-size: 40px;
}
}
HTML
<div class="header-container">
<header class="title">
JOSEPH.HOW<span>ARTH</span>
</header>
<!-- nav defaults to display:none, comes in w/ animation-->
<nav>
<div id="about-nav" href="#"><p>About Me</p></div>
<div id="proj-nav" href="#"><p>Projects</p></div>
<div id="resume-nav" href="#"><p>Resume</p></div>
</nav>
Use #-webkit-keyframes for safari
#keyframes banner-up {
50% {
border-bottom: 1px #111 solid;
}
100% {
height: 80px;
border-bottom: 3px #111 solid;
}
}
/* Safari */
#-webkit-keyframes banner-up {
50% {
border-bottom: 1px #111 solid;
}
100% {
height: 80px;
border-bottom: 3px #111 solid;
}
}
Related
I made this simple animation. But when I "unhover" the transitioned spans just "disappear". Is there any easy way to slide the spans back, aka. reverse the transition after unhover.
Or if necessary any complicated way?
If possible it would be great if the solution is CSS only.
Thanks in advance!
#container {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
#wrapper {
position: relative;
font-family: 'Courier New', Courier, monospace;
}
#wrapper h2 {
font-size: 8rem;
margin: 0px;
}
#wrapper:hover span:first-of-type {
visibility: visible;
transform: translate(0%, 0%);
}
#wrapper:hover span:last-of-type {
transform: translate(0%, 0%);
visibility: visible;
}
#wrapper span {
font-size: 8rem;
font-weight: bold;
transition: transform 1s;
}
#wrapper span:first-of-type {
position: absolute;
top: 0%;
left: 0%;
z-index: 1;
transform: translate(-10%, -100%);
visibility: hidden;
background: linear-gradient(45deg, #00ff00, #00ff80);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
#wrapper span:last-of-type {
position: absolute;
top: 0%;
left: 50%;
z-index: 1;
transform: translate(10%, 100%);
visibility: hidden;
background: linear-gradient(45deg, #00ff80, aqua);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
<div id="container">
<div id="wrapper">
<h2>Hi</h2>
<span>H</span>
<span>i</span>
</div>
</div>
Because visibilty cannot be animated smoothly, thus it is recommended to use a scalable value for visibility animation such as opacity.
#container {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
#wrapper {
position: relative;
font-family: 'Courier New', Courier, monospace;
}
#wrapper h2 {
font-size: 8rem;
margin: 0px;
}
#wrapper:hover span:first-of-type {
opacity: 1;
transform: translate(0%, 0%);
}
#wrapper:hover span:last-of-type {
transform: translate(0%, 0%);
opacity: 1;
}
#wrapper span {
font-size: 8rem;
font-weight: bold;
transition: transform 1s, opacity 1s;
}
#wrapper span:first-of-type {
position: absolute;
top: 0%;
left: 0%;
z-index: 1;
transform: translate(-10%, -100%);
opacity: 0;
background: linear-gradient(45deg, #00ff00, #00ff80);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
#wrapper span:last-of-type {
position: absolute;
top: 0%;
left: 50%;
z-index: 1;
transform: translate(10%, 100%);
opacity: 0;
background: linear-gradient(45deg, #00ff80, aqua);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
<div id="container">
<div id="wrapper">
<h2>Hi</h2>
<span>H</span>
<span>i</span>
</div>
</div>
But if you have to animate visibility for some reason, you may specify the animation-timing-function of visibility to step-end to make it disappear at the last moment:
#wrapper:not(:hover) span {
transition: transform 1s, visibility 1s step-end;
}
#container {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
#wrapper {
position: relative;
font-family: 'Courier New', Courier, monospace;
}
#wrapper h2 {
font-size: 8rem;
margin: 0px;
}
#wrapper:hover span:first-of-type {
visibility: visible;
transform: translate(0%, 0%);
}
#wrapper:hover span:last-of-type {
transform: translate(0%, 0%);
visibility: visible;
}
#wrapper span {
font-size: 8rem;
font-weight: bold;
transition: transform 1s;
}
#wrapper span:first-of-type {
position: absolute;
top: 0%;
left: 0%;
z-index: 1;
transform: translate(-10%, -100%);
visibility: hidden;
background: linear-gradient(45deg, #00ff00, #00ff80);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
#wrapper span:last-of-type {
position: absolute;
top: 0%;
left: 50%;
z-index: 1;
transform: translate(10%, 100%);
visibility: hidden;
background: linear-gradient(45deg, #00ff80, aqua);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
/* added */
#wrapper:not(:hover) span {
transition: transform 1s, visibility 1s step-end;
}
<div id="container">
<div id="wrapper">
<h2>Hi</h2>
<span>H</span>
<span>i</span>
</div>
</div>
Hi I was wondering if I could get any advice on how to do a animation such as this in react native: https://codepen.io/gayane-gasparyan/pen/jOmaBQK
It uses a mixture of keyframes, linear gradients but is a CSS based animation.
I have react-native-reanimated and native-base and can also leverage these modules if necessary.
Main CSS code:
.card {
background: #191c29;
width: var(--card-width);
height: var(--card-height);
padding: 3px;
position: relative;
border-radius: 6px;
justify-content: center;
align-items: center;
text-align: center;
display: flex;
font-size: 1.5em;
color: rgb(88 199 250 / 0%);
cursor: pointer;
font-family: cursive;
}
.card:hover {
color: rgb(88 199 250 / 100%);
transition: color 1s;
}
.card:hover:before, .card:hover:after {
animation: none;
opacity: 0;
}
.card::before {
content: "";
width: 104%;
height: 102%;
border-radius: 8px;
background-image: linear-gradient(
var(--rotate)
, #5ddcff, #3c67e3 43%, #4e00c2);
position: absolute;
z-index: -1;
top: -1%;
left: -2%;
animation: spin 2.5s linear infinite;
}
.card::after {
position: absolute;
content: "";
top: calc(var(--card-height) / 6);
left: 0;
right: 0;
z-index: -1;
height: 100%;
width: 100%;
margin: 0 auto;
transform: scale(0.8);
filter: blur(calc(var(--card-height) / 6));
background-image: linear-gradient(
var(--rotate)
, #5ddcff, #3c67e3 43%, #4e00c2);
opacity: 1;
transition: opacity .5s;
animation: spin 2.5s linear infinite;
}
#keyframes spin {
0% {
--rotate: 0deg;
}
100% {
--rotate: 360deg;
}
}
a {
color: #212534;
text-decoration: none;
font-family: sans-serif;
font-weight: bold;
margin-top: 2rem;
}
I worked with this tutorial, and coded this:
Splitting();
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: monospace;
}
body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background: grey;
}
.circle {
transform-style: preserve-3d;
animation: animate 8s linear infinite;
}
.circle .char {
position: absolute;
top: 0;
left: 0;
background: blue;
color: red;
font-size: 4em;
padding: 5px 12px;
border-top: 4px solid black;
border-bottom: 4px solid black;
transform-style: preserve-3d;
transform-origin: center;
transform: rotateY(calc(var(--char-index) * 12deg)) translateZ(250px);
}
#keyframes animate {
0% {
transform: perspective(1000px) rotateY(360deg) rotateX(15deg);
}
100% {
transform: perspective(1000px) rotateY(0deg) rotateX(15deg);
}
}
<script src="https://unpkg.com/splitting/dist/splitting.min.js"></script>
<div class="circle" data-splitting>
Circle-Text-Animation-Effects-
</div>
Unfortunately, I realized that it doesn't work with Chrome and Firefox. They don't show the curvature. I tried to fix it with Autoprefixer, but it didn't help. Has anyone an idea how to solve this issue?
Here is how it should look like, and how it looks like with Safari:
There is an extra span around your letters that need to have transform-style: preserve-3d;
Splitting();
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: monospace;
}
body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background: grey;
}
.circle {
transform-style: preserve-3d;
animation: animate 8s linear infinite;
}
/* added this */
.circle > span {
transform-style: preserve-3d;
display: block;
}
/**/
.circle .char {
position: absolute;
top: 0;
left: 0;
background: blue;
color: red;
font-size: 4em;
padding: 5px 12px;
border-top: 4px solid black;
border-bottom: 4px solid black;
transform-style: preserve-3d;
transform-origin: center;
transform: rotateY(calc(var(--char-index) * 12deg)) translateZ(250px);
}
#keyframes animate {
0% {
transform: perspective(1000px) rotateY(360deg) rotateX(15deg);
}
100% {
transform: perspective(1000px) rotateY(0deg) rotateX(15deg);
}
}
<script src="https://unpkg.com/splitting/dist/splitting.min.js"></script>
<div class="circle" data-splitting>
Circle-Text-Animation-Effects-
</div>
I have a situation where I am modifying an element using a hover pseudo class both when its parent is hovered over and when it is hover over. Unfortunately, they have a conflicting property (both trying to define the property transform), which is why -- I assume -- the scaling is not working when the button is hovered over but the cursor change is. Is there a work around using just CSS?
body {
overflow: hidden;
}
#action-panel {
align-items: center;
box-sizing: border-box;
display: flex;
flex-direction: column;
justify-content: center;
padding: 20px 20px 20px 20px;
position: absolute;
right: 0;
transform: translateY(-50%);
top: 50%;
}
#action-panel:hover .action-button {
opacity: 1;
transform: translateX(0);
}
.action-button {
background-color: lightblue;
border-radius: 25px;
height: 50px;
margin-bottom: 20px;
opacity: 0;
transition: opacity 200ms ease-in-out, transform 200ms ease-in-out;
transform: translateX(calc(100% + 20px));
width: 50px;
}
.action-button:hover {
cursor: pointer;
transform: translateX(0) scale(1.2);
}
.action-button span {
font-size: 30px;
left: 50%;
position: relative;
transform: translate(-50%, -50%);
top: 50%;
}
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<div id="action-panel">
<div class="action-button"><span class="material-icons">3d_rotation</span></div>
<div class="action-button"><span class="material-icons">compare_arrows</span></div>
<div class="action-button"></div>
</div>
Note:
If you cannot tell from the code, you need to move your cursor to the middle of the right edge to see the effects I am describing.
Increased the specificity of the following style by adding #action-panel before it. In your code the hover styles of parent were overriding the hover styles of child.
#action-panel .action-button:hover {
cursor: pointer;
transform: translateX(0) scale(1.2);
}
body {
overflow: hidden;
}
#action-panel {
align-items: center;
box-sizing: border-box;
display: flex;
flex-direction: column;
justify-content: center;
padding: 20px 20px 20px 20px;
position: absolute;
right: 0;
transform: translateY(-50%);
top: 50%;
}
#action-panel:hover .action-button {
opacity: 1;
transform: translateX(0);
}
.action-button {
background-color: lightblue;
border-radius: 25px;
height: 50px;
margin-bottom: 20px;
opacity: 0;
transition: opacity 200ms ease-in-out, transform 200ms ease-in-out;
transform: translateX(calc(100% + 20px));
width: 50px;
}
#action-panel .action-button:hover {
cursor: pointer;
transform: translateX(0) scale(1.2);
}
.action-button span {
font-size: 30px;
left: 50%;
position: relative;
transform: translate(-50%, -50%);
top: 50%;
}
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<div id="action-panel">
<div class="action-button"><span class="material-icons">3d_rotation</span></div>
<div class="action-button"><span class="material-icons">compare_arrows</span></div>
<div class="action-button"></div>
</div>
i have a little issue with the css animation and keyframe feature...
i have a little monster with blinking eyes... the eyes should blink just 0.1s
And then i want to have a duration... and then the animation should loop.
This is my animation/keyframe:
#keyframes blinkingEyes {
0% {
transform: rotateX(0deg);
}
36% {
transform: rotateX(90deg);
}
100% {
transform: rotateX(90deg);
}
}
And this is my animation property:
animation: blinkingEyes 0.15s 1s infinite linear;
JSFIDDLE
I found a workaround with a x% between my start and end value. But nothing works for me.. i hope you could help me
You need several keyframes for this, and then make the animation run infinite times.
See:
#monster {
margin-top: 60px;
height: 93px;
width: 75px;
border-radius: 120px;
background: yellow;
/* text-align: center; */
position: relative;
}
.eye {
height: 12px;
width: 8px;
background: black;
border-radius: 10px;
margin-top: 30px;
float: left;
animation: blinkingEyes 1.5s linear infinite;
}
.eyeLeft {
margin-left: 18px;
}
.eyeRight {
margin-left: 22px;
}
.mouth {
font-weight: 900;
transform-origin: 50% 50%;
/* display: inline-block; */
width: 5px;
margin: 0 auto;
height: 20px;
/* text-align: center; */
/* left: 47%; */
position: absolute;
top: 47px;
transform: rotate(90deg);
left: 35px;
}
#keyframes blinkingEyes {
0%, 97%, 100% {
transform: rotateX(0deg);
}
98%, 99% {
transform: rotateX(90deg);
}
}
<div id="monster">
<div class="monsterBody">
<div class="eye eyeLeft">
</div>
<div class="eye eyeRight">
</div>
<div class="mouth">
)
</div>
</div>
</div>