so I am a html and css starter, I wanted to make this cool startup animation which when hovered will rotate and expand like in the code and later I am planing to add a button in between. Till now it works fine but I am stuck on how can I reverse animate it to close, when the mouse in not hovering and also the code is very lengthy so is there a way to make it shorter.
↑ I know this isn't the best explanation. so if you dont understand just run the code and maybe you'll get it.
/*
=======================
Variable
=======================
*/
:root {
/* -----colors----- */
--clr-blue-1: #0C164F;
--clr-blue-2: #5643FD;
--clr-purple-1: #0D0717;
--clr-purple-2: #1D1135;
--clr-purple-3: #7649FE;
--clr-gray-1: #B9A2FE;
--clr-white: #FCFBFE;
--clr-pink-1: #BA1E68;
/* -----fonts----- */
--ff-primary: 'Barlow', sans-serif;
--ff-secondary: 'Nova Square', cursive;
/* --cross animation-- */
--cross-animation-time: 1s;
--cross-opacity: 0.6;
/* -----other----- */
--transition: all 0.3s linear;
--spacing: 0.25rem;
}
/*
=======================
Global CSS
=======================
*/
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: var(--ff-primary);
background-color: var(--clr-white);
color: var(--clr-purple-1);
line-height: 1.5;
font-size: 0.875rem; /* 14 px */
}
a {
text-decoration: none;
}
img {
display: block;
width: 100%;
}
h1,h2,h3,h4,h5 {
text-transform: capitalize;
letter-spacing: var(--spacing);
margin-bottom: 0.75rem;
line-height: 1.25;
}
h1 { font-size: 3rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 0.875rem; }
p { margin-bottom: 1.25rem; }
.clearfix::after, .clearfix::before{
content: "";
clear: both;
display: table;
}
#media screen and (min-width: 800px) {
h1 { font-size: 4rem; }
h2 { font-size: 2.5rem; }
h3 { font-size: 2rem; }
h4 { font-size: 1rem; }
}
/*
=======================
Header Section
=======================
*/
.header {
min-height: 100vh;
background: linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7)), url(https://wallpaperaccess.com/full/17520.jpg);
background-repeat: no-repeat;
background-size: cover;
background-position: center;
text-align: center;
display: flex;
justify-content: center;
align-items: center;
}
.head-arrows {
background: var(--clr-white);
opacity: 0.4;
display: inline-block;
}
.inline-breaker {
display: block;
}
.arrow-left, .arrow-right {
display: inline-block;
}
.arrow-left {
margin-right: 1.5rem;
}
.arrow-right {
margin-left: 1.5rem;
}
.arrow-up-left {
width: 1.5rem;
height: 6rem;
transform: skewY(45deg);
/* animation: CrossUpLeft 1s ease-in-out 1; */
}
.banner:hover .arrow-up-left {
animation: CrossUpLeft var(--cross-animation-time) ease-in-out 1;
animation-fill-mode: forwards;
}
.arrow-up-right {
width: 1.5rem;
height: 6rem;
transform: skewY(-45deg);
/* animation: CrossUpRight 1s ease-in-out 1; */
}
.banner:hover .arrow-up-right {
animation: CrossUpRight var(--cross-animation-time) ease-in-out 1;
animation-fill-mode: forwards;
}
.arrow-left-up {
display: block;
width: 6rem;
height: 1.5rem;
transform: skewX(45deg);
}
.banner:hover .arrow-left-up {
animation: CrossLeftUp var(--cross-animation-time) ease-in-out 1;
animation-fill-mode: forwards;
}
.arrow-left-down {
display: block;
width: 6rem;
height: 1.5rem;
transform: skewX(-45deg);
}
.banner:hover .arrow-left-down {
animation: CrossLeftDown var(--cross-animation-time) ease-in-out 1;
animation-fill-mode: forwards;
}
.arrow-right-up {
display: block;
width: 6rem;
height: 1.5rem;
transform: skewX(-45deg);
}
.banner:hover .arrow-right-up {
animation: CrossRightUp var(--cross-animation-time) ease-in-out 1;
animation-fill-mode: forwards;
}
.arrow-right-down {
display: block;
width: 6rem;
height: 1.5rem;
transform: skewX(45deg);
}
.banner:hover .arrow-right-down {
animation: CrossRightDown var(--cross-animation-time) ease-in-out 1;
animation-fill-mode: forwards;
}
.arrow-down-left {
width: 1.5rem;
height: 6rem;
transform: skewY(-45deg);
}
.banner:hover .arrow-down-left {
animation: CrossDownLeft var(--cross-animation-time) ease-in-out 1;
animation-fill-mode: forwards;
}
.arrow-down-right {
width: 1.5rem;
height: 6rem;
transform: skewY(45deg);
}
.banner:hover .arrow-down-right {
animation: CrossDownRight var(--cross-animation-time) ease-in-out 1;
animation-fill-mode: forwards;
}
/*
=======================
Animation Section
=======================
*/
#keyframes CrossUpLeft {
5% {
transform: translate(0rem,-1rem) skewY(45deg);
}
50% {
transform: translate(-6rem,4.5rem) skewY(45deg);
}
95% {
transform: translate(0rem,15rem) skewY(45deg);
}
100% {
opacity: var(--cross-opacity);
transform: translate(0,13rem) skewY(45deg);
}
}
#keyframes CrossUpRight {
5% {
transform: translate(0rem,-1rem) skewY(-45deg);
}
50% {
transform: translate(-6rem,4.5rem) skewY(-45deg);
}
95% {
transform: translate(0rem,15rem) skewY(-45deg);
}
100% {
opacity: var(--cross-opacity);
transform: translate(0,13rem) skewY(-45deg);
}
}
#keyframes CrossLeftUp {
5% {
transform: translate(-1rem,0) skewX(45deg);
}
50% {
transform: translate(4.5rem,6rem) skewX(45deg);
}
95% {
transform: translate(15rem,0) skewX(45deg);
}
100% {
opacity: var(--cross-opacity);
transform: translate(13rem,0) skewX(45deg);
}
}
#keyframes CrossLeftDown {
5% {
transform: translate(-1rem,0) skewX(-45deg);
}
50% {
transform: translate(4.5rem,6rem) skewX(-45deg);
}
95% {
transform: translate(15rem,0) skewX(-45deg);
}
100% {
opacity: var(--cross-opacity);
transform: translate(13rem,0) skewX(-45deg);
}
}
#keyframes CrossRightUp {
5% {
transform: translate(1rem,0) skewX(-45deg);
}
50% {
transform: translate(-4.5rem,-6rem) skewX(-45deg);
}
95% {
transform: translate(-15rem,0) skewX(-45deg);
}
100% {
opacity: var(--cross-opacity);
transform: translate(-13rem,0) skewX(-45deg);
}
}
#keyframes CrossRightDown {
5% {
transform: translate(1rem,0) skewX(45deg);
}
50% {
transform: translate(-4.5rem,-6rem) skewX(45deg);
}
95% {
transform: translate(-15rem,0) skewX(45deg);
}
100% {
opacity: var(--cross-opacity);
transform: translate(-13rem,0) skewX(45deg);
}
}
#keyframes CrossDownLeft {
5% {
transform: translate(0,1rem) skewY(-45deg);
}
50% {
transform: translate(6rem,-4.5rem) skewY(-45deg);
}
95% {
transform: translate(0,-15rem) skewY(-45deg);
}
100% {
opacity: var(--cross-opacity);
transform: translate(0,-13rem) skewY(-45deg);
}
}
#keyframes CrossDownRight {
5% {
transform: translate(0,1rem) skewY(45deg);
}
50% {
transform: translate(6rem,-4.5rem) skewY(45deg);
}
95% {
transform: translate(0,-15rem) skewY(45deg);
}
100% {
opacity: var(--cross-opacity);
transform: translate(0,-13rem) skewY(45deg);
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- ----------------------------CSS link--------------------------- -->
<link rel="stylesheet" href="style.css">
<!-- --------------------------Google fonts------------------------- -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Barlow:wght#300;400;500&family=Nova+Square&display=swap" rel="stylesheet">
<!-- --------------------------Font Awesome------------------------- -->
<link rel="stylesheet" href="C:\Users\com\Desktop\AFFAN\VisualStudio Codes\ICONS\fontawesome-free-5.15.4-web\css\all.css">
<title>Index</title>
</head>
<body>
<!-- ---------------------------
Header section
---------------------------- -->
<header class="header">
<div class="banner">
<div class="head-arrows arrow-up-left"></div><div
class="head-arrows arrow-up-right"></div><div class="inline-breaker"></div><div class="arrow-left">
<div class="head-arrows arrow-left-up"></div>
<div class="head-arrows arrow-left-down"></div>
</div><div class="arrow-right">
<div class="head-arrows arrow-right-up"></div>
<div class="head-arrows arrow-right-down"></div></div><div
class="inline-breaker"></div><div
class="head-arrows arrow-down-left"></div><div
class="head-arrows arrow-down-right"></div>
</div>
</header>
</body>
</html>
Related
I'm building an animation for cards. I wonder how to have the same effect for the card animation however without animating the z-index. The animation should use only transform and opacity properties.
I want to achieve the same effect(as demonstrated below) without using z-index in the animation, because it will cause painting to occur.
*,
::before,
::after {
padding: 0;
margin: 0;
box-sizing: border-box;
}
body {
font-family: Arial, Helvetica, sans-serif;
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}
.container {
position: relative;
}
.item {
padding: 8px;
background-color: blue;
color: white;
opacity: 0;
height: 30px;
width: 32px;
text-align: center;
position: absolute;
top: auto;
bottom: 0;
animation: AnimateCard 16s infinite
cubic-bezier(0.48, 0.18, 0.35, 1.01);
}
.item:nth-child(1) {
animation-delay: -9s;
}
.item:nth-child(2) {
animation-delay: -5s;
}
.item:nth-child(3) {
animation-delay: -1s;
}
.item:nth-child(4) {
animation-delay: 3s;
}
#keyframes AnimateCard {
0% {
transform: translateY(-72px);
z-index: 1;
opacity: 0;
}
26% {
transform: translateY(-72px);
z-index: 1;
opacity: 0.2;
}
34% {
transform: translateY(-36px);
z-index: 1;
opacity: 0.3;
}
51% {
transform: translateY(-36px);
z-index: 1;
opacity: 0.3;
}
58% {
transform: translateY(0);
opacity: 1;
}
74% {
transform: translateY(0);
opacity: 1;
}
100% {
transform: translateY(0);
opacity: 0;
}
}
<div class="container">
<div class="item">1</div>
<div class="item">2</div>
<div class="item">3</div>
<div class="item">4</div>
</div>
In order to achieve a more marked fading effect between 4 and 1, I've applied two changes:
removed z-index from keyframes
changed 100% keyframe with 83%, so that it will fade away before 100%.
Here's the full snippet:
*,
::before,
::after {
padding: 0;
margin: 0;
box-sizing: border-box;
}
body {
font-family: Arial, Helvetica, sans-serif;
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}
.container {
position: relative;
}
.item {
padding: 8px;
background-color: blue;
color: white;
opacity: 0;
height: 30px;
width: 32px;
text-align: center;
position: absolute;
top: auto;
bottom: 0;
animation: AnimateCard 16s infinite
cubic-bezier(0.48, 0.18, 0.35, 1.01);
}
.item:nth-child(1) {
animation-delay: -9s;
}
.item:nth-child(2) {
animation-delay: -5s;
}
.item:nth-child(3) {
animation-delay: -1s;
}
.item:nth-child(4) {
animation-delay: 3s;
}
#keyframes AnimateCard {
0% {
transform: translateY(-72px);
opacity: 0;
}
26% {
transform: translateY(-72px);
opacity: 0.2;
}
34% {
transform: translateY(-36px);
opacity: 0.3;
}
51% {
transform: translateY(-36px);
opacity: 0.3;
}
58% {
transform: translateY(0);
opacity: 1;
}
74% {
transform: translateY(0);
opacity: 1;
}
83% {
transform: translateY(0);
opacity: 0;
}
}
<div class="container">
<div class="item">1</div>
<div class="item">2</div>
<div class="item">3</div>
<div class="item">4</div>
</div>
We can clip the bottom most rectangle to height 0 as top one collapse on it:
*,
::before,
::after {
padding: 0;
margin: 0;
box-sizing: border-box;
}
body {
font-family: Arial, Helvetica, sans-serif;
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}
.container {
position: relative;
}
.item {
padding: 8px;
background-color: blue;
color: white;
opacity: 0;
height: 30px;
width: 32px;
text-align: center;
position: absolute;
top: auto;
bottom: 0;
animation: AnimateCard 16s infinite cubic-bezier(0.48, 0.18, 0.35, 1.01);
}
.item:nth-child(1) {
animation-delay: -9s;
}
.item:nth-child(2) {
animation-delay: -5s;
}
.item:nth-child(3) {
animation-delay: -1s;
}
.item:nth-child(4) {
animation-delay: 3s;
}
#keyframes AnimateCard {
0% {
transform: translateY(-72px);
opacity: 0;
}
26% {
transform: translateY(-72px);
opacity: 0.2;
}
34% {
transform: translateY(-36px);
opacity: 0.3;
}
51% {
transform: translateY(-36px);
opacity: 0.3;
}
58% {
transform: translateY(0);
opacity: 1;
}
74% {
transform: translateY(0);
opacity: 1;
}
76% {
clip: rect(0px, 32px, 32px, 0px);
}
85% {
clip: rect(32px, 32px, 32px, 0px);
}
100% {
transform: translateY(0);
opacity: 0;
}
}
<div class="container">
<div class="item">1</div>
<div class="item">2</div>
<div class="item">3</div>
<div class="item">4</div>
</div>
I removed z-index from keyframes and just do small changes into your existing CSS style code so check below snippet.
*,::before, ::after {
padding: 0;
margin: 0;
box-sizing: border-box;
}
body {
font-family: Arial, Helvetica, sans-serif;
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
margin: 0;
padding: 0;
}
.container {
position: relative;
box-shadow: 0 0 0 1px red;
height: 200px;
width: 64px;
overflow: hidden;
}
.item {
display: flex;
align-items: center;
justify-content: center;
padding: 8px;
background-color: blue;
color: white;
height: 60px;
width: 64px;
text-align: center;
position: absolute;
top: auto;
bottom: 0;
animation: AnimateCard 16s infinite cubic-bezier(0.48, 0.18, 0.35, 1.01);
}
.item:nth-child(1) {
animation-delay: -9s;
}
.item:nth-child(2) {
animation-delay: -5s;
}
.item:nth-child(3) {
animation-delay: -1s;
}
.item:nth-child(4) {
animation-delay: 3s;
}
#keyframes AnimateCard {
0% {
transform: translateY(-210px);
opacity: 0;
}
26% {
transform: translateY(-140px);
opacity: 0.5;
}
34% {
transform: translateY(-70px);
opacity: 0.2;
}
51% {
transform: translateY(-70px);
opacity: 0.2;
}
58% {
transform: translateY(0);
opacity: 1;
}
74% {
transform: translateY(0);
opacity: 1;
}
91% {
transform: translateY(140px);
opacity: 1;
}
100% {
transform: translateY(210px);
opacity: 0;
}
}
<div class="container">
<div class="item">1</div>
<div class="item">2</div>
<div class="item">3</div>
<div class="item">4</div>
</div>
The animation lowers the height of the h1 and then once the animation is completed, it snaps back into position.
.main-header {
position: absolute;
top: 40%;
left: 50%;
transform: translate(-50%, -50%);
animation-name: moveInLeft;
animation-duration: 1s;
animation-timing-function: ease-out;
}
.wrap {
background-color: gray;
height: 90vh;
}
#keyframes moveInLeft {
0% {
opacity: 0;
transform: translateX(-100px);
}
80% {
transform: translateX(10px);
}
100% {
opacity: 1;
transform: translate(0);
}
}
<header class="wrap">
<h1 class="main-header">
This is a header
</h1>
</header>
Avoid not checking the whole code before posting it here.
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
nav {
border: white solid 1px;
}
.header-container {
display: flex;
justify-content: space-between;
position: relative;
}
.main-nav {
display: flex;
}
.main-nav li {
list-style-type: none;
}
h1.main-header {
position: absolute;
top: 40%;
left: 50%;
transition: left, top;
animation-name: moveInLeft;
animation-duration: 1s;
animation-timing-function: ease-out;
}
.wrap {
background-color: gray;
height: 90vh;
}
#keyframes moveInLeft {
0% {
opacity: 0;
transform: translateX(-100px);
}
60% {
transform: translateX(150px);
}
100% {
opacity: 1;
transform: translateX(0px);
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="css/style.css">
<title>Hello World!</title>
</head>
<body>
<header class="wrap">
<nav class="header-container">
<h2 class="header-text">
Text
</h2>
<ul class="main-nav">
<li>Home</li>
<li>About</li>
<li>Contact</li>
</ul>
</nav>
<h1 class="main-header">
This is a header
</h1>
</header>
</body>
</html>
This should work as expected. Note the different use of transform: translate; and transition: left, top;, since transform: translate; is used to move the object for defined value(here 50% both X and Y) and you haven't set the returning position to match starting point, thus I've made it simple and used transition: left, top; and changed only value of X to move right then return left.
this happening because of translate(-50% ,-50%) wich is replaced by aniamtion transform.
if you want to center your header you can use flex display on the header parent like this:
.main-header {
animation-name: moveInLeft;
animation-duration: 1s;
animation-timing-function: ease-out;
animation-repeat:infinite;
animation-iteration-count: infinite;
}
.wrap {
background-color: gray;
height: 90vh;
display:flex;
align-items:center;
justify-content:space-around
}
#keyframes moveInLeft {
0% {
opacity: 0;
transform: translateX(-100px);
}
80% {
transform: translateX(10px);
}
100% {
opacity: 1;
transform: translate(0);
}
}
<header class="wrap">
<h1 class="main-header">
This is a header
</h1>
</header>
.main-header {
position: absolute;
top: 40%;
left: 50%;
transform: translate(-50%, -50%);
animation-name: moveInLeft;
animation-duration: 1s;
animation-timing-function: ease-out;
}
.wrap {
background-color: gray;
height: 90vh;
}
#keyframes moveInLeft {
0% {
opacity: 0;
transform: translateX(-100px);
}
80% {
transform: translateX(10px);
}
100% {
opacity: 1;
transform: translate(0);
}
}
<header class="wrap">
<h1 class="main-header">
This is a header
</h1>
</header>
because you have specific height:90vh on your .wrap parent you can use align-items:center for vertical align the header and justify-content work for horizontal align.
You just need to use animation-fill-mode:forwards; check MDN for the property details.
.main-header {
position: absolute;
top: 40%;
left: 50%;
transform: translate(-50%, -50%);
animation-name: moveInLeft;
animation-duration: 1s;
animation-timing-function: ease-out;
animation-fill-mode:forwards;
}
.wrap {
background-color: gray;
height: 90vh;
}
#keyframes moveInLeft {
0% {
opacity: 0;
transform: translateX(-100px);
}
80% {
transform: translateX(10px);
}
100% {
opacity: 1;
transform: translate(0);
}
}
<header class="wrap">
<h1 class="main-header">
This is a header
</h1>
</header>
I have some moving word css3 animation.
The animation is fine (snippet). If someone use hover the animation stops (fine), but don't accept a change of the opacity and z-index (.bubble:hover).
opacity: 1;
z-index: 100;
The .bubble:hover class is in use the transform action works.
transform: scale(1.2);
The aim is to pop the hovered bubble in the foreground.
If the bubble is left the animation should move on from the point of stop.
How can I fix it?
Thanks for help.
.solSystem {
postion: absolute;
height: 25vw;
}
.orbitLink,
.orbitLink:active,
.orbitLink:visited {
color: #FFF;
}
.mars:hover,
.earth:hover {
animation-play-state: paused;
}
.bubble:hover {
background: #DE383B !Important;
padding: 1vw;
border: 0.1vw solid #000;
color: #FFF !Important;
transform: scale(1.2);
opacity: 1;
z-index: 100;
}
.mars {
float: left;
margin: 4vw auto;
border-radius: 50%;
position: absolute;
animation-name: moveRigthToLeft, scale, color;
animation-iteration-count: infinite, infinite;
animation-timing-function: ease-in-out, linear;
}
.earth {
float: left;
margin: 4vw auto;
border-radius: 50%;
position: absolute;
animation-name: moveLeftToRigth, scale, color;
animation-iteration-count: infinite, infinite;
animation-timing-function: ease-in-out, linear;
}
.bubble {
padding: 1vw;
color: #FFF;
border-color: #000;
border-width: 0.1vw;
background-color: #004A99;
font-weight: bold;
font-size: 1.1vw;
font-family: Arial, FreeSans, sans-serif;
position: absolute;
border-style: solid;
border-radius: 100%;
}
#keyframes moveLeftToRigth {
0% {
left: 15vw;
}
50% {
left: 40vw;
}
100% {
left: 15vw;
}
}
#keyframes scale {
0% {
transform: scale(1);
}
32% {
transform: scale(0.7);
animation-timing-function: ease-in;
}
70% {
transform: scale(0.8);
animation-timing-function: ease-in;
}
75% {
transform: scale(0.9);
animation-timing-function: ease-in-out;
}
86% {
transform: scale(1.2);
}
98% {
transform: scale(1.1);
}
100% {
transform: scale(1);
}
}
#keyframes color {
0% {
opacity: 0.5;
z-index: 1;
}
20% {
opacity: 0.6;
z-index: 2;
}
40% {
opacity: 0.7;
z-index: 3;
}
60% {
opacity: 0.8;
z-index: 4;
}
80% {
opacity: 0.9;
z-index: 5;
}
90% {
opacity: 1;
z-index: 6;
}
95% {
opacity: 0.8;
z-index: 4;
}
100% {
opacity: 0.6;
z-index: 2;
}
}
<div class="solSystem">
<a href="Test1.html">
<div class="earth" style="animation-duration: 20s,20s,20s;">
<div class="bubble" style="left:12vw;">
Test1
</div>
</div>
</a>
<a href="Test2.html">
<div class="mars" style="animation-duration: 30s,30s,30s;">
<div class="bubble" style="left:30vw;">
Test2
</div>
</div>
</a>
</div>
This happend cause you gave to parent div less opacity with "color" keyframes and then apply that animation to parent of a hovered div. You should make color changes on "bubble" div.
codepen:
http://codepen.io/bra1N/pen/dXKLbp
.solSystem {
postion: absolute;
height: 25vw;
}
.orbitLink,
.orbitLink:active,
.orbitLink:visited {
color: #FFF;
}
.mars:hover,
.earth:hover {
animation-play-state: paused;
}/*
.bubble:hover {
background: #DE383B !Important;
padding: 1vw;
border: 0.1vw solid #000;
color: #FFF !Important;
transform: scale(1.2);
opacity: 1 !important;
z-index: 100 !important;
}*/
.mars {
float: left;
margin: 4vw auto;
border-radius: 50%;
position: absolute;
animation-name: moveRigthToLeft, scale;
animation-iteration-count: infinite, infinite;
animation-timing-function: ease-in-out, linear;
}
.earth {
float: left;
margin: 4vw auto;
border-radius: 50%;
position: absolute;
animation-name: moveLeftToRigth, scale;
animation-iteration-count: infinite, infinite;
animation-timing-function: ease-in-out, linear;
}
.bubble {
padding: 1vw;
color: #FFF;
border-color: #000;
border-width: 0.1vw;
background-color: #004A99;
font-weight: bold;
font-size: 1.1vw;
font-family: Arial, FreeSans, sans-serif;
position: absolute;
border-style: solid;
border-radius: 100%;
animation-name: color;
animation-iteration-count: infinite;
animation-duration: 30s;
}
#keyframes moveLeftToRigth {
0% {
left: 15vw;
}
50% {
left: 40vw;
}
100% {
left: 15vw;
}
}
#keyframes scale {
0% {
transform: scale(1);
}
32% {
transform: scale(0.7);
animation-timing-function: ease-in;
}
70% {
transform: scale(0.8);
animation-timing-function: ease-in;
}
75% {
transform: scale(0.9);
animation-timing-function: ease-in-out;
}
86% {
transform: scale(1.2);
}
98% {
transform: scale(1.1);
}
100% {
transform: scale(1);
}
}
#keyframes color {
0% {
opacity: 0.4;
z-index: 1;
}
20% {
opacity: 0.6;
z-index: 2;
}
40% {
opacity: 0.7;
z-index: 3;
}
60% {
opacity: 0.8;
z-index: 4;
}
80% {
opacity: 0.9;
z-index: 5;
}
90% {
opacity: 1;
z-index: 6;
}
95% {
opacity: 0.8;
z-index: 4;
}
100% {
opacity: 0.6;
z-index: 2;
}
}
<div class="solSystem">
<a href="Test1.html">
<div class="earth" style="animation-duration: 20s,20s,20s;">
<div class="bubble" style="left:12vw;">
Test1
</div>
</div>
</a>
<a href="Test2.html">
<div class="mars" style="animation-duration: 30s,30s,30s;">
<div class="bubble" style="left:30vw;">
Test2
</div>
</div>
</a>
</div>
I have a rotate animation that I am symbolizing that something is loading. This works great (except it doesn't rotate continuously, it kind of stops some when it has went around 360 degrees), but on some phones (I have an android note 4) it doesn't spin at all. Then on others (iphones) my circle actually rotates like it is swinging or it is fixed at one corner of the circle and it spins from that axis.
I have webkits in my code and I have the img set to this:
#spinning-circle img {
width: 100%;
height: auto;
}
Why would my image be doing these things. I can give the web url to see this live if you want to see it in a mobile setting.
#spinning-circle-container {
float: left;
width: 40%;
background: red;
padding: 140px 0 0 10%;
}
#spinning-circle {
animation-name: spinning-circle;
animation-duration: 4s;
animation-iteration-count: infinite;
width: 100px;
height: 100px;
}
#spinning-circle img {
width: 100%;
height: auto;
}
#-webkit-keyframes spinning-circle {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
#spinning-circle-title {
padding-top: 35px;
color: #000;
font-size: 2.8em;
}
#media screen and (max-width:640px) {
#spinning-circle-container {
width: 80%;
padding: 40px 0 0 6%;
}
#spinning-circle {
animation-name: spinning-circle;
animation-duration: 4s;
animation-iteration-count: infinite;
width: 50px;
height: 50px;
}
#spinning-circle img {
width: 100%;
height: auto;
}
#-webkit-keyframes spinning-circle {
0% {
-webkit-transform: rotate(0deg);
-webkit-transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
-webkit-transform: rotate(360deg);
}
}
#spinning-circle-title {
padding-top: 35px;
color: blue;
font-size: 1.5em;
}
}
<div id="spinning-circle-container">
<div id="spinning-circle">
<img src="http://optimumwebdesigns.com/images/spinning-circle.png">
</div>
<div id="spinning-circle-title">LOADING...</div>
</div>
You need to use prefixed -webkit-transform in prefixed #webkit-keyframes and not-prefixed transform in not-prefixed #keyframes. And also you need to add prefixed -webkit-animation.
If you want animation doesn't stop at the end, you could use animation-timing-function: linear, but then animation'll have a constant speed.
You don't need to duplicate #keyframes and other properties inside #media screen {}.
#spinning-circle-container {
float: left;
width: 40%;
background: red;
padding: 140px 0 0 10%;
}
#spinning-circle {
-webkit-animation: spinning-circle linear 2s infinite;
animation: spinning-circle linear 2s infinite;
width: 100px;
height: 100px;
}
#spinning-circle img {
width: 100%;
height: auto;
}
#spinning-circle-title {
padding-top: 35px;
color: #000;
font-size: 2.8em;
}
#media screen and (max-width: 640px) {
#spinning-circle-container {
width: 80%;
padding: 40px 0 0 6%;
}
#spinning-circle {
width: 50px;
height: 50px;
}
#spinning-circle-title {
color: blue;
font-size: 1.5em;
}
}
#-webkit-keyframes spinning-circle {
0% {
-webkit-transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
}
}
#keyframes spinning-circle {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
<div id="spinning-circle-container">
<div id="spinning-circle">
<img src="http://optimumwebdesigns.com/images/spinning-circle.png">
</div>
<div id="spinning-circle-title">LOADING...</div>
</div>
You have to add animation-timing-function: linear; in your animation definition.
Here you have a code working https://jsfiddle.net/xhurpqLd/
-- EDIT --
You also have
#-webkit-keyframes spinning-circle {
0% {
-webkit-transform: rotate(0deg) ;
-webkit-transform: rotate(0deg) ;
}
100% {
-webkit-transform: rotate(360deg) ;
-webkit-transform: rotate(360deg) ;
}
}
You only define the transform for webkit. Change to
#-webkit-keyframes spinning-circle {
0% {
-webkit-transform: rotate(0deg) ;
transform: rotate(0deg) ;
}
100% {
-webkit-transform: rotate(360deg) ;
transform: rotate(360deg) ;
}
}
Here you have the updated code https://jsfiddle.net/xhurpqLd/3/. It works on my Android.
You can also add -ms-transform for IE support.
Lines 731-733 and 1391-1393 of main-style.css appear to be causing the swinging problem.
*::after, *::before {
content: '';
}
should be
*::after, *::before {
content: '';
display: table;
}
assuming you're trying to use this clearfix method
I have the following HTML:
<div id="square" class="zoomInUp animated"> <p class="header-name">Theo Bearman</p>
<p class="header-title">Interests in <span class="rw-words rw-words-1">
<span>Web Designer</span>
<span>Web Developer</span>
<span>Graphic Designer</span>
</span></p></div>
And the following CSS:
/* Animated words ------------------------------------------------- */
.rw-words{
text-indent: 10px;
font-size: 16px;
font-weight: 100;
text-align: center
}
.rw-words-1 span{
position: absolute;
opacity: 0;
overflow: hidden;
-webkit-animation: rotateWord 9s linear infinite 0s;
-ms-animation: rotateWord 9s linear infinite 0s;
animation: rotateWord 9s linear infinite 0s;
text-align: center
}
.rw-words-1 span:nth-child(2) {
-webkit-animation-delay: 3s;
-ms-animation-delay: 3s;
animation-delay: 3s;
}
.rw-words-1 span:nth-child(3) {
-webkit-animation-delay: 6s;
-ms-animation-delay: 6s;
animation-delay: 6s;
}
#-webkit-keyframes rotateWord {
0% { opacity: 0; }
2% { opacity: 0; -webkit-transform: translateY(-30px); }
5% { opacity: 1; -webkit-transform: translateY(0px);}
25% { opacity: 1; -webkit-transform: translateY(0px); }
40% { opacity: 0; -webkit-transform: translateY(30px); }
80% { opacity: 0; }
100% { opacity: 0; }
}
#-ms-keyframes rotateWord {
0% { opacity: 0; }
2% { opacity: 0; -ms-transform: translateY(-30px); }
5% { opacity: 1; -ms-transform: translateY(0px);}
25% { opacity: 1; -ms-transform: translateY(0px); }
40% { opacity: 0; -ms-transform: translateY(30px); }
80% { opacity: 0; }
100% { opacity: 0; }
}
#keyframes rotateWord {
0% { opacity: 0; }
2% { opacity: 0; -webkit-transform: translateY(-30px); transform: translateY(-30px); }
5% { opacity: 1; -webkit-transform: translateY(0px); transform: translateY(0px);}
25% { opacity: 1; -webkit-transform: translateY(0px); transform: translateY(0px); }
40% { opacity: 0; -webkit-transform: translateY(30px); transform: translateY(30px); }
80% { opacity: 0; }
100% { opacity: 0; }
}
#media screen and (max-width: 768px){
.rw-sentence { font-size: 18px; }
}
#media screen and (max-width: 320px){
.rw-sentence { font-size: 9px; }
}
.header-name2 {
background-color: #000;
padding: 5px 17px;
display: inline-block;
color: #fff;
font-size: 13px;
font-weight: 400;
text-transform: uppercase;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
border-left: 3px solid #f00;
border-right: 3px solid #0045ff;
}
.header-title {
font-size: 16px;
font-weight: 100;
}
What would I need to do to change my code so that header-title is centered underneath header-name2 with the scrolling words included?
A live example is here. You can see that the text "Interests in" is centered but the scrolling words are not.
Thanks in advance!
You can do this:
.rw-words{
....
display: block;
position: relative;
}
.rw-words-1 span{
left:25%;
right: 25%;
}
and remove text-indent from .rw-words
You could give .header-title { margin-left: -110px; }
<div class="rw-words rw-words-1">
<div id = 'cont'></div>
<div>Web Designer</div>
<div>Web Developer</div>
<div>Graphic Designer</div>
</div>
Put a blank container div in there
#cont {
position:relative;
width: 10em;
}
Problem is absolute position is not taking up any "space"
and therefore not computed in centering.