clubmate.fi

A good[ish] website

Web development blog, loads of UI and JavaScript topics

Making trippy shapes with CSS border and animating them to give you epilepsy

Filed under: Styling— Tagged with: CSS, animation

Animating CSS border property can result in in pretty spacey looking things. I just played around with it and stuff appeared.

The basics

The gist of this experiments is to:

  • Make the border as wide as the box itself.
  • Set different colors for the different borders.
  • Then play with the border styles
  • And animate it, of course.
.module {
  border-color: #84be88 #695c83 #c87a61 #edc42c;
  border-width: 100px;
  box-sizing: border-box;
  float: left;
  height: 200px;
  margin: 0 20px 20px 0;
  width: 200px;
}

Trigger the animation on hover:

.module:hover {
  animation: border-animation 2s linear infinite;
}

The border width keyframe animation looks something like this:

@keyframes border-animation {
  0% {
    border-width: 100px;
  }
  50% {
    border-width: 0;
  }
  100% {
    border-width: 100px;
  }
}

Borders on all sides same width

This examples uses a border on all sides of the component.

.module {
  border-width: 100px;
}

See a Demo zKGHC

Borders only on left and right

.module {
  border-width: 0px 100px 0px 100px;
}

See a Demo goruJ

These can get crazy

This one is the trippiest of them all:

See a Demo okDzd

Conclusion

I have no idea how to use there... maybe they’re purpose is not be useful at all.

Comments would go here, but the commenting system isn’t ready yet, sorry.

  • © 2022 Antti Hiljá
  • About
  • All rights reserved yadda yadda.
  • I can put just about anything here, no one reads the footer anyways.
  • I love u!