Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Is it possible to do gradient text and shining text effect at the same time?

I want to apply shining text effect (https://codepen.io/fazlurr/pen/qbWMRv)

.shine {
    // set background
    background: #222 -webkit-gradient(linear, left top, right top, from(#222), to(#222), color-stop(0.5, #fff)) 0 0 no-repeat;
    -webkit-background-size: 150px;
    color: $text-color;
    -webkit-background-clip: text;
    -webkit-animation-name: shine;
    -webkit-animation-duration: $duration;
    -webkit-animation-iteration-count: infinite;
    text-shadow: 0 0px 0px rgba(255, 255, 255, 0.5);
}

and gradient text (https://cssgradient.io/blog/css-gradient-text/)

h1 {
  font-size: 72px;
  background: -webkit-linear-gradient(#eee, #333); // set background
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

at the same time. The color for shining text and gradient text are different. I saw both effect need to set background and "-webkit-background-clip: text", so I can’t achieve the desirable result (setting background for one override another). Is there any way to apply these 2 effects at the same time?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You need multiple background and make sure to check the date of the demos/articles you find online. The shine effect you are using is very very old and using an outdated syntax

h1 {
  font-size: 72px;
  font-weight: bold;
  font-family: sans-serif;
  background: 
    /* the shine layer */
    linear-gradient(-45deg, #0000 40%,#fff5,#0000 60%)
     right/300% 100%,
    /* the color layer*/
    linear-gradient(45deg,red, blue);
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
  color:#000;
  animation: shine 2s infinite;
}

@keyframes shine {
  to {background-position: left;}
}

body {
 background: #000;
}
<h1>Shine Bright Like a Diamond</h1>

Related: Responsive shine animation using linear-gradient as background

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading