akasoggybunz akasoggybunz - 1 year ago 93
Sass (Sass) Question

CSS/HTML Animation Circle to Square. Which property/attribute determines the Shape?

In the included example found on codepen from CSS-Tricks , which
property in the css code determines the shape of the div?

I understand most of the css properties here. I am just wondering what
determines the shape, and if there is a way to describe/or make other
shapes. For example a star or triangle.

I am new to css and would like to learn the language, especially
animation tricks.

.element {
height: 250px;
width: 250px;
margin: 0 auto;
background-color: red;
animation-name: stretch;
animation-duration: 1.5s;
animation-timing-function: ease-out;
animation-delay: 0;
animation-direction: alternate;
animation-iteration-count: infinite;
animation-fill-mode: none;
animation-play-state: running;

@keyframes stretch {
0% {
transform: scale(.3);
background-color: red;
border-radius: 100%;
50% {
background-color: orange;
100% {
transform: scale(1.5);
background-color: yellow;

html {
height: 100%;

body {
display: flex;
align-items: center;
justify-content: center;

<div class="element"></div>

Answer Source

The shape here is determined by border-radius, which can be used to round out the edges of an HTML element (turning a box into a rounded rectangle), or with enough radius (or border-radius: 50%), it can transform a square element into a circle. There's no similar way to produce other shapes (triangle, star, etc), though there are many outside-the-box and creative ways to do this, like using borders to make a CSS triangle.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download