I'm really a newbie when it comes to CSS - but I saw this cool effect with using the text as a mask for the background. I got it working just fine but have set my mind on trying to animate the background to continuously slide to the left. I just can't make it work.
h1 {
font-family: Poppins;
font-size: 12rem;
color: transparent;
background-image: url(people.jpg);
background-size: cover;
background-repeat: repeat-x;
background-clip: text;
-webkit-background-clip: text;
animation: slide_background 15s linear infinite;
}
#keyframes slide_background {
from {
transform: translateX(0);
}
to {
transform: translateX(-100%);
}
}
<h1>PEOPLE</h1>
it slides alright... but so does the text mask.
How do keep the text stationary while the background slides to the side?
change it to this:
#keyframes slide_background {
from {
background-position: 0px 0px;
}
to {
background-position: 100% 0px;
}
}
Now it's working! Thanks #Temani Afif for point out what I did wrong.
For infos: you may also use mix-blend-mode and text-indent for the animation
h1 {
font-family: Poppins;
font-size: 12rem;
position: relative;
z-index: 1;
background: white;
margin: 0;
animation: slide_background 15s linear infinite;
}
h1:before {
content: "";
mix-blend-mode: screen;
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
background: url(http://lorempixel.com/output/fashion-q-c-640-480-10.jpg);
background-size: cover;
}
#keyframes slide_background {
from {
text-indent: 0;
}
to {
text-indent: -100vw;
}
}
<h1>PEOPLE</h1>
Related
I'm following a tutorial on youtube on how to create a Glowing Border Animation with CSS
I tried to implement it myself and was pretty successful, however, I encountered a problem which I'm unable to solve. When I view my animation there is an uneven transition. It looks like as if two images are stuck together where the colours transition is cut off.
How can I solve the issue there with my transition looks smooth?
I created a JSFiddle to display what I mean:
* {
margin: 0;
padding: 0;
}
body {
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background: #151320;
}
.box {
position: relative;
width: 300px;
height: 300px;
color: #fff;
font: 300 2rem 'Montserrat';
text-align: center;
text-transform: uppercase;
display: flex;
align-items: center;
}
.box::before,
.box::after {
content: '';
z-index: -1;
position: absolute;
width: calc(100% + 30px);
height: calc(100% + 30px);
top: -15px;
left: -15px;
background: linear-gradient(45deg, #0096FF, #0047AB, #000000, #6082B6, #87CEEB, #00008B, #145DA0, #00008B, #145DA0, #0096FF, #0047AB, #000000, #6082B6, #87CEEB);
background-repeat: repeat;
border-radius: 5px;
background-size: 600%;
animation: border 12s linear infinite;
}
.box::after {
filter: blur(25px);
}
#keyframes border {
0% {
background-position: 0% 0%;
}
100% {
background-position: 250% 250%;
}
}
<link href='https://fonts.googleapis.com/css?family=Montserrat' rel='stylesheet'>
<div class="box">
Greetings fellow developer!
</div>
Note: The animation looks smooth at first but after about 7ish seconds you encounter the "cut off" where the transition doesn't line up.
Your gradient need to have a kind of repetition to achieve such effect. Make its size 200% 200% then use a repeating gradient where the first color start at 0% and the last one at 50%. Notice how the list of color is repeated twice but in the opposite order.
body {
background: #151320;
}
.box {
position: relative;
width: 300px;
height: 300px;
}
.box::before,
.box::after {
content: '';
z-index: -1;
position: absolute;
inset: -15px;
background:
repeating-linear-gradient(45deg,
#0096FF 0%, #0047AB, #6082B6, #87CEEB, #00008B,
#00008B, #87CEEB, #6082B6,#0047AB,#0096FF 50%);
border-radius: 5px;
background-size: 200% 200%;
animation: border 2s linear infinite;
}
.box::after {
filter: blur(25px);
}
#keyframes border {
0% {
background-position: bottom left;
}
100% {
background-position: top right;
}
}
<div class="box">
</div>
I'm trying to create shine effect on my text like here: https://codepen.io/avstorm/pen/WNrMqjG
My problem is that my text is colorized and the shine in the codepen above is working only when the text is in one color.
I tried my best but got here so far:
https://codepen.io/naoranhaisy/pen/RwZQeeN
HTML:
<span class="shine logoText">
<span>Peer</span>
<span>Anfon</span>
<span>infrustructre</span>
</span>
CSS:
.logoText span:first-child {
color: #4361ad;
font-size: 30px;
}
.logoText span:nth-child(2) {
color: #dfdfdf;
font-size: 29px;
}
.logoText span:nth-child(3) {
font-size: 16px;
color: #dfdfdf;
margin-right: 5px;
}
.shine {
text-align: center;
background: linear-gradient(to right, #222, #fff);
background-size: 15px 100%;
background-clip: border-box;
background-clip: initial;
background-repeat: no-repeat;
background-position: 0 0;
animation: shimmer 2s infinite ease-in-out;
-webkit-animation: shimmer 2s infinite ease-in out;
}
#keyframes shimmer {
0% {
background-position: top left;
}
100% {
background-position: top right;
}
}
(As you can see it's not really good...)
Can any css master can help me? Thank you!
I have some text that I want to animate. The text should change color from white to green from top to bottom. I want the new color to basically drop from the top.
body{
background-color: lightblue;
}
#test {
animation: changeColor infinite;
animation-timing-function: ease-out;
animation-duration: 5s;
font-size: 40px;
color:white;
}
#keyframes changeColor {
0% {
color: linear-gradient(to bottom, white, #2E7D32 50%) bottom;
}
100% {
color: green;
}
}
<div id="test">The</div>
An Example
Source for the below snippet. The following animation occurs on hover, however this is just an example to demonstrate what I wish to achieve. Some changes I require are that the font colour should change from top to bottom and it should use keyframes(animation).
#import url("https://fonts.googleapis.com/css?family=Barlow:800&display=swap");
* {
box-sizing: border-box;
}
*::before,
*::after {
box-sizing: border-box;
}
body {
font-family: "Barlow", sans-serif;
display: flex;
align-items: center;
justify-content: center;
margin: 0;
min-height: 100vh;
}
a {
position: relative;
display: inline-block;
font-size: 2em;
font-weight: 800;
color: royalblue;
overflow: hidden;
background: linear-gradient(to right, midnightblue, midnightblue 50%, royalblue 50%);
background-clip: text;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-size: 200% 100%;
background-position: 100%;
transition: background-position 275ms ease;
text-decoration: none;
}
a:hover {
background-position: 0 100%;
}
Link Hover
background + background-clip might be what you look for:
because of a demo (below) it could not be just a comment :) .
reset the gradient to your needs if you need a sharp color transition
body{
background:lightblue;
}
#test {
animation: changeColor infinite linear 5s forwards;
font-size: 40px;
color:transparent;
background:linear-gradient(to bottom, #2E7D32 , white, #2E7D32 ) bottom left/ 100% 600% ;
background-clip:text;
}
#keyframes changeColor {
to { background-position: top left;
}
}
<div id="test">The</div>
I figured out how to accomplish, so I'm answering my own question.
let titleIDThe = document.getElementById("titleIDThe");
titleIDThe.classList.add("animateColor");
.animateColor {
animation: changeColor infinite;
animation-timing-function: ease-out;
animation-duration: 10s;
background-image: linear-gradient(to bottom, red 50%, #2E7D32 50%);
background-position: 0% 0%;
background-size: 100% 200%;
background-clip: text;
-webkit-background-clip: text;
color: transparent;
width: 50vw;
height: 50vh;
font-size: 30px;
}
#keyframes changeColor {
0% {
background-position: 0% 0%;
}
20% {
background-position: 0% -100%;
}
30% {
background-position: 0% -100%;
}
50% {
background-position: 0% 0%;
}
100% {
background-position: 0% 0%;
}
}
<span id="titleIDThe">The</span>
I've got this sample sprite grid sheet that I need to run through and animate. I am able to reach a certain point but struggling to make it perfect. The animation is not that smooth and additionally, the image is not aligned properly. During the animation, you can see image elements not centered with other elements in the view. Here is my HTML and CSS3 code so far.
.hi {
width: 910px;
height: 340px;
background-image: url("https://simba-heroku.imgix.net/animation-homepage-tablet-retina.jpg?auto=format,compress");
position: relative;
-webkit-animation: playv 12s steps(6) infinite, playh 2s steps(4) infinite;
}
#-webkit-keyframes playv {
0% { background-position-y: 0px; }
100% { background-position-y: 100%; }
}
#-webkit-keyframes playh {
0% { background-position-x: 0px; }
100% { background-position-x: 100%; }
}
<div class="hi">
</div>
Fiddle: http://jsfiddle.net/bf5ckdv9/
I have added a background dimension style, and rearranged some of your properties
the result is almost ok; but your sprite grid seems to be out of order
.hi {
width: 910px;
height: 340px;
background-image: url("https://simba-heroku.imgix.net/animation-homepage-tablet-retina.jpg?auto=format,compress");
position: relative;
animation: playh 2s steps(5) infinite, playv 10s steps(5) infinite;
border: solid 1px blue;
background-size: 500% 500%;
background-repeat: no-repeat;
}
#keyframes playv {
0% { background-position-y: 0px; }
100% { background-position-y: 125%; }
}
#keyframes playh {
0% { background-position-x: 0%; }
100% { background-position-x: 125%; }
}
<div class="hi">
</div>
I'm trying to recreate the material design ripple effect in pure CSS, and I have the animation prepared. The problem is, I can't make the animation run all the way through when the element is clicked. I've tried with transitions (attempt 1 demo, attempt 2 demo), but neither of these will run all of the way through.
The other more likely method is with CSS3 animations (I'm not worried about browser support right now). I have the animation keyframes ready, but I've never worked with animations very much before and I don't see a way to run the animation upon clicking.
#-webkit-keyframes ripple {
0% {
background-size: 1% 1%;
opacity: 0.5;
}
70% {
background-size: 1000% 1000%;
opacity: 0.2;
}
100% {
opacity: 0;
background-size: 1000% 1000%;
}
}
#keyframes ripple {
0% {
background-size: 1% 1%;
opacity: 0.5;
}
70% {
background-size: 1000% 1000%;
opacity: 0.2;
}
100% {
opacity: 0;
background-size: 1000% 1000%;
}
}
.button {
background-color: blue;
padding: 12px;
display: inline-block;
border-radius: 5px;
color: white;
font-family: sans-serif;
text-transform: uppercase;
position: relative;
overflow: hidden;
}
.button::after {
position: absolute;
content: " ";
height: 100%;
width: 100%;
top: 0;
left: 0;
pointer-events: none;
background-image: radial-gradient(circle at center, #FFF 0%, #FFF 10%, transparent 10.1%, transparent 100%);
background-position: center center;
background-repeat: no-repeat;
background-color: transparent;
-webkit-animation: ripple 0.6s 0s normal forwards infinite running ease-in;
animation: ripple 0.6s 0s normal forwards infinite running ease-in;
}
.button:active::after {
/*Somehow the animation needs to run on click only, and then run all the way through*/
}
<div class="ripple button"><a>Click this</a></div>
Somethings I've thought about but have been unable to make work include changing the animation delay, making the ::after transparent using opacity, and using the animation timing function.
Try this out but you need to use jquery to keep the button active , i didn't used jquery therefore hold the click;
#-webkit-keyframes ripple {
0% {
background-size: 1% 1%;
opacity: 0.5;
}
70% {
background-size: 1000% 1000%;
opacity: 0.2;
}
100% {
opacity: 0;
background-size: 1000% 1000%;
}
}
#keyframes ripple {
0% {
background-size: 1% 1%;
opacity: 0.5;
}
70% {
background-size: 1000% 1000%;
opacity: 0.2;
}
100% {
opacity: 0;
background-size: 1000% 1000%;
}
}
.button {
background-color: blue;
padding: 12px;
display: inline-block;
border-radius: 5px;
color: white;
font-family: sans-serif;
text-transform: uppercase;
position: relative;
overflow: hidden;
}
.button:active:after{
position: absolute;
content: " ";
height: 100%;
width: 100%;
top: 0;
left: 0;
pointer-events: none;
background-image: radial-gradient(circle at center, #FFF 0%, #FFF 10%, transparent 10.1%, transparent 100%);
background-position: center center;
background-repeat: no-repeat;
background-color: transparent;
-webkit-animation: ripple 0.6s 0s normal forwards infinite running ease-in;
animation: ripple 0.6s 0s normal forwards infinite running ease-in;}
<div class='ripple button'><a href=''>hell</a></div>
I've have done this another way:
With :focus the styles stays active. You can view it here:
http://codepen.io/jonnitto/pen/OVmvPB?editors=110