css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <link href="https://fonts.googleapis.com/css?family=Quicksand:300,400,500,700" rel="stylesheet">
	<div class="warning">
		This page uses <a href="https://css-tricks.com/snippets/css/complete-guide-grid/" title="CSS Grid Layout" target="_blank">CSS Grid Layout</a>. If you are reading this message, your browser does not support this feature and you may not be able to see a grid of example boxes. You can check the browser compatibility <a href="http://caniuse.com/#feat=css-grid" title="Can I Use CSS Grid Layout" target="_blank">here</a>.
	</div>
	<h1>Simple Animations using CSS Borders</h1>
	<h3>Hover your mouse on the examples below to see the effect.</h3>
	<div class="grid-container">
		<div>
			<h2>1. Interchange border colors</h2>
			<div class="box box1"></div>
		</div>
		<div>
			<h2>2. Expand width</h2>
			<div class="box box2"></div>
		</div>
		<div>
			<h2>3. Expand width &amp; height</h2>
			<div class="box box3"></div>
		</div>
		<div>
			<h2>4. Rotate border colors using keyframe animations</h2>
			<div class="box box4"></div>
		</div>
		<div>
			<h2>5. Four colored circle</h2>
			<div class="box box5"></div>
		</div>
		<div>
			<h2>6. Two colored triangle</h2>
			<div class="box box6"></div>
		</div>
		<div>
			<h2>7. Two colored square</h2>
			<div class="box box7"></div>
		</div>
		<div>
			<h2>8. Missing top border</h2>
			<div class="box box8"></div>
		</div>
		<div>
			<h2>9. Down Arrow</h2>
			<div class="box box9"></div>
		</div>
		<div>
			<h2>10. Left Arrow</h2>
			<div class="box box10"></div>
		</div>
		<div>
			<h2>11. Up Arrow</h2>
			<div class="box box11"></div>
		</div>
		<div>
			<h2>12. Right Arrow</h2>
			<div class="box box12"></div>
		</div>
	</div>

	<footer>
		<a href="https://github.com/mpsinghk/animations-using-css-borders" title="Fork on GitHub" target="_blank">Fork on GitHub</a>
	</footer>
            
          
!
            
              /* Base
------------------------------------------------------- */
body {
  font-family: 'Quicksand', sans-serif;
  font-size: calc(16px + 0.3vw);
  font-weight: 300;
  line-height: 1.4;
  text-align: center;
  padding: 40px 30px 30px;
}

/* Typography
------------------------------------------------------- */
h1 {
  font-size: 3.2em;
  line-height: 1.1;
  font-weight: 700;
  margin: 0 0 0.3em;
}

h2 {
  font-size: 1.2em;
  line-height: 1.3;
  font-weight: 400;
  margin: 0 0 0.8em;
}

a,
a:hover,
a:focus {
  text-decoration: none;
  color: #00a7e3;
}

/* Footer
------------------------------------------------------- */
footer {
  font-size: 0.9em;
  padding: 20px;
  margin-top: 50px;
  border-top: 1px solid #ccc;
}

/* CSS Grid Layout
------------------------------------------------------- */
.grid-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
  grid-gap: 20px;
}

.grid-container > div {
  border: 1px solid #ccc;
  padding: 30px;
  -webkit-box-sizing: border-box;
          box-sizing: border-box;
}

/* Warning message if using old browser
that does not support CSS Grid Layout.
------------------------------------------------------- */
.warning {
  padding: 20px;
  margin-bottom: 30px;
  background: #f7b563;
  border: 1px solid #e88d1a;
  border-radius: 3px;
}

.warning a {
  color: #fff;
}

@supports (display: grid) {
  .warning {
    display: none;
  }
}

/* Example boxes
------------------------------------------------------- */
.box {
  display: inline-block;
  cursor: pointer;
  width: 100px;
  height: 100px;
  border-width: 35px;
  border-style: solid;
  border-color: cyan magenta yellow black;
  -webkit-transition: all 0.3s ease-in-out;
  transition: all 0.3s ease-in-out;
}

.box1:hover,
.box1:focus {
  border-color: yellow black cyan magenta;
}

.box2 {
  width: 0;
}

.box2:hover,
.box2:focus {
  width: 100px;
}

.box3 {
  width: 0;
  height: 0;
}

.box3:hover,
.box3:focus {
  width: 100px;
  height: 100px;
}

@-webkit-keyframes rotate-borders {
  25% { border-color: black cyan magenta yellow; }
  50% { border-color: yellow black cyan magenta; }
  75% { border-color: magenta yellow black cyan; }
  100% { border-color: cyan magenta yellow black; }
}

@keyframes rotate-borders {
  25% { border-color: black cyan magenta yellow; }
  50% { border-color: yellow black cyan magenta; }
  75% { border-color: magenta yellow black cyan; }
  100% { border-color: cyan magenta yellow black; }
}

.box4 {
  -webkit-animation: rotate-borders 6s infinite;
          animation: rotate-borders 6s infinite;
}

.box5:hover,
.box5:focus {
  border-radius: 50%;
}

.box6:hover,
.box6:focus {
  width: 0;
  height: 0;
  border-width: 85px;
  border-color: transparent magenta yellow transparent;
}

.box7:hover,
.box7:focus {
  width: 0;
  height: 0;
  border-width: 0 170px 170px 0;
  border-color: transparent magenta yellow transparent;
}

.box8:hover,
.box8:focus {
  width: 0;
  height: 0;
  border-width: 85px;
  border-color: transparent magenta yellow black;
}

.box9:hover,
.box9:focus {
  width: 0;
  height: 0;
  border-width: 170px 85px 0 85px;
  border-color: cyan transparent transparent transparent;
}

.box10:hover,
.box10:focus {
  width: 0;
  height: 0;
  border-width: 85px 170px 85px 0;
  border-color: transparent magenta transparent transparent;
}

.box11:hover,
.box11:focus {
  width: 0;
  height: 0;
  border-width: 0 85px 170px 85px;
  border-color: transparent transparent yellow transparent;
}

.box12:hover,
.box12:focus {
  width: 0;
  height: 0;
  border-width: 85px 0 85px 170px;
  border-color: transparent transparent transparent black;
}
            
          
!
            
              // Find me on Instagram
// https://www.instagram.com/mpsinghk
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console