background-clip

In this example below you will see how to do a background-clip with some HTML / CSS and Javascript

Thumbnail
This awesome code was written by postor, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright postor ©

Technologies

  • HTML
  • CSS
  • JavaScript
<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  <title>background-clip</title>
  
  
  
      <link rel="stylesheet" href="css/style.css">

  
</head>

<body>

  
<div class="clip">background clip clip </div>
  <script src='https://code.jquery.com/jquery-2.2.4.min.js'></script>

  

    <script  src="js/index.js"></script>




</body>

</html>

/*Downloaded from https://www.codeseek.co/postor/background-clip-OXoagV */
.clip {
  font-size: 260px;
  font-weight: bold;
  background: repeating-linear-gradient(-45deg, #ff0000 0px, #00ff00 235.7px, #0000ff 471.4px, #ff0000 707.1px);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  width: 1000px;
  height: 1000px;
}

.clip.d45 {
  background: repeating-linear-gradient(-45deg, #ff0000 0px, #00ff00 235.7px, #0000ff 471.4px, #ff0000 707.1px);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}


/*Downloaded from https://www.codeseek.co/postor/background-clip-OXoagV */
var $c = $('.clip');
var posX = 0;
var posY = 0;
var timeout = Math.random()*1000;

function flow(){
  console.log([$c,posX,posY]);
  posX+=500;
  posY+=500;
  timeout = Math.random()*1000;
  $c.css('-webkit-transition', (timeout/1000)+'s linear');
  $c.css('background-position',posX+'px '+posY+'px');
  setTimeout(flow,timeout)
}
flow();

Comments