Pen Settings

HTML

CSS

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

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Behavior

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div id="app">
	<div class="title">
		<h1>Clip-Path: Simple Movements</h1>
	</div>
	<div class="panel">
		<label for="shapes">Animations</label>
		<select id="shapes" v-model="currentTransition">
			<option value="down">down</option>
      <option value=box-wipe>box wipe</option>
      <option value="rotate">rotate</option>
      <option value="spotlight">spotlight</option>
		</select>
		
		<label for="modes">Modes</label>
		<select id="modes" v-model="mode">
			<option value="">none</option>
			<option value="out-in">out-in</option>
			<option value="in-out">in-out</option>
		</select>
		
		<button @click="transition">transition</button>
	</div>
	<div class="boxes">
		<transition :name="currentTransition" :mode="mode">
      <box1 v-if="box1"></box1>
      <box2 v-else></box2>
    </transition>		
	</div>
	<div class="example">
		<transition name="fade" mode="out-in">
			<div class="container" :key="currentTransition" v-html="descriptions[currentTransition]"></div>
		</transition>
	</div>
	<div class="instructions">
		<ul>
			<li>Choose from five different types of clip-path animations in the "Animations" dropdown.</li>
			<li>Choose from the different Vue Transition Component modes in the "Modes" dropdown that control the order of the boxes transitioning.</li>
			<li>Click the "Transition" button to see the selected options being animated.</li>
		</ul>
	</div>
</div>

              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=Luckiest+Guy');

html {
  box-sizing: border-box;
  font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;
}
*, *:before, *:after {
  box-sizing: inherit;
}
html,
body {
  background-color: #1d1e22;
  margin: 0;
  padding: 0;
}
body {
	align-items: center;
	display: flex;
	height: 100vh;
	justify-content: center;
}

#app {
	display: grid;
  grid-template-columns: 150px 300px 350px;
  grid-gap: 20px;
	
	.title {
		color: #FFF;
		grid-column: 1 / 4;
	
		h1 {
			font-size: 20px;
			font-weight: bold;
		}
	}
	
	.instructions {
		color: #FFF;
		grid-column: 1 / 4;
		
		ul {
			list-style: disc;
		}
		li {
			margin-bottom: 10px;
		}
	}
}


.panel {
	display: flex;
	flex-direction: column;
	
	label {
		color: #fff;
	}
	
	button,
	select {
		font-size: 18px;
		margin: 10px 0;
		padding: 5px 0;
	}
}

.boxes {
  align-items: center;
  background-color: #C5C5C5;
  border: 3px solid #FFF;
  display: flex;
  height: 300px;
  justify-content: center;
  width: 300px;
  
  &::before {
    background-color: darken(#C5C5C5, 10%);
    content: '';
    display: block;
    height: 200px;
    position: absolute;
    width: 200px;
  }
  &::after {
    align-items: center;
    background-color: rgba(0, 0, 0, 0.8);
    color: #fff;
    content: "Sorry!\A\AThis browser doesn't support this type of clip-path animations!";
    display: flex;
    height: 200px;
    position: absolute;
    text-align: center;
    white-space: pre-wrap;
    width: 200px;
  }
	
	.box {
		align-items: center;
		background-color: #307B21;
		color: #fff;
		display: flex;
		font-family: 'Luckiest Guy';
		font-size: 60px;
		height: 200px;
		justify-content: center;
		position: absolute;
		width: 200px;
	}
	.box2 {
		background-color: #4371AD;
	}
}
@supports(clip-path: inset(0)) {
  .boxes::after {
    display: none;
  }
}

.example {
	color: #FFF;
	
	p {
		margin-bottom: 10px;
	}
  .container {
    width: 350px;
  }
}

.fade-enter,
.fade-leave-to { opacity: 0; }
.fade-enter-active,
.fade-leave-active { transition: 500ms; position: absolute; }

.down-enter-active { animation: 1s down-enter; }
.down-leave-active { animation: 1s down-leave; }
@keyframes down-enter {
  0% { clip-path: inset(0 0 100% 0); }
  100% { clip-path: inset(0); }
}
@keyframes down-leave {
  0% { clip-path: inset(0); }
  100% { clip-path: inset(100% 0 0 0); }
}

.box-wipe-enter-active { animation: 1s box-wipe-enter; }
.box-wipe-leave-active { animation: 1s box-wipe-leave; }
@keyframes box-wipe-enter {
  0% { clip-path: inset(25% 100% 25% -50%); }
  50% { clip-path: inset(25% 0% 25% 50%); }
  100% { clip-path: inset(0); }
}
@keyframes box-wipe-leave {
  0% { clip-path: inset(0); }
  50% { clip-path: inset(25% 50% 25% 0%); }
  100% { clip-path: inset(25% -50% 25% 100%); }
}

.rotate-enter-active { animation: 1s rotate reverse; }
.rotate-leave-active { animation: 1s rotate; }
@keyframes rotate {
  0% { clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%); }
  25% { clip-path: polygon(87.5% 12.5%, 87.5% 87.5%, 12.5% 87.5%, 12.5% 12.5%); }
  50% { clip-path: polygon(75% 75%, 25% 75%, 25% 25%, 75% 25%); }
  75% { clip-path: polygon(37.5% 62.5%, 37.5% 37.5%, 62.5% 37.5%, 62.5% 62.5%); }
  100% { clip-path: polygon(50% 50%, 50% 50%, 50% 50%, 50% 50%); }
}

.spotlight-enter-active { animation: 2s spotlight reverse; }
.spotlight-leave-active { animation: 2s spotlight; }
@keyframes spotlight {
  0% { clip-path: circle(100% at 50% 50%); }
  25% { clip-path: circle(20% at 50% 50%); }
  50% { clip-path: circle(20% at 12% 84%); }
  75% { clip-path: circle(20% at 93% 51%); }
  100% { clip-path: circle(20% at -30% 20%); }
}
              
            
!

JS

              
                Vue.component('box1', {
	template: '<div class="box box1">box1</div>'
});
Vue.component('box2', {
	template: '<div class="box box2">box2</div>'
});

new Vue({
  el: "#app",
  data: {
  	box1: true,
    currentTransition: 'down',
    mode: 'out-in',
		descriptions: {
			down: '<p>The down animation uses the inset shape in two different animations to push the sides in a downward direction.</p><p>The leave transition starts with all four sides at 0 and then animates the top down to 100%.</p><p>The enter transition starts with the bottom side already pushed upward 100% and then animates the bottom down to 0.</p>',
      'box-wipe': '<p>The box wipe animation uses the inset shape to create a box that shrinks down to the left side and then moves off the right side.</p><p>The leave transition shrinks the large square to a half-size square placed on the left side of the element. It then moves the square to the right beyond the edge of the element.</p><p>The enter animation does the same in reverse.</p>',
      rotate: '<p>The rotate animation uses the polygon shape to create a rotating square.</p><p>The leave transition animates the square\'s four vertices inward and clockwise over five keyframes. This movement gives the appearance of a rotating and shrinking square.</p><p>The enter transition does the same in reverse giving the appearance of a rotating and growing square.</p>',
      spotlight: '<p>The spotlight animation uses the circle shape over five keyframes.</p><p>The leave transition starts with shrinking the circle from 100% down to 20% in the center. The next four keyframes animate the location of the circle to various spots in the box area until it moves off the left side.</p><p>The enter transition does the same in reverse.</p>'
		}
  },
  methods: {
  	transition () {
    	this.box1 = !this.box1;
    }
  }
})
              
            
!
999px

Console