How To Create Clip Path Border Animation

In this topic,

We are going to see how to create clip path border animation.

<div>Hello Prince</div>

The pseudo-elements can be utilized as the background for clipping and animation in this case because the elements will be clipped. clip-path meaning there won’t be any little triangles created by the trimmed border. Additionally supported by this method are rounded border-radius corners.

Step-2: Add CSS Code in the <style>…</style> on index.html file.

body, html {
  width: 100%;
  height: 100%;
  display: flex;
div {
  position: relative;
  margin: auto;
  width: 120px;
  line-height: 64px;
  text-align: center;
  color: #fff;
  font-size: 20px;
  border: 2px solid gold;
  border-radius: 10px;
  background: #c9cd7e;
  transition: all 0.3s;
  cursor: pointer;
div:hover {
  filter: contrast(1.1);
div:active {
  filter: contrast(0.9);
div::before, div::after {
  content: "";
  position: absolute;
  top: -10px;
  left: -10px;
  right: -10px;
  bottom: -10px;
  border: 2px solid gold;
  transition: all 0.5s;
  animation: clippath 3s infinite linear;
  border-radius: 10px;
div::after {
  animation: clippath 3s infinite -1.5s linear;
@keyframes clippath {
  0%, 100% {
    clip-path: inset(0 0 98% 0);
  25% {
    clip-path: inset(0 98% 0 0);
  50% {
    clip-path: inset(98% 0 0 0);
  75% {
    clip-path: inset(0 0 0 98%);
.bg::before {
  background: rgba(255, 215, 0, 0.5);

Review the below video.

I hope you guys found something useful.

Submit a Comment

Your email address will not be published.


Select Categories