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

              
                
<main id="vue-context">

	<form class="price" action="javascript:void()">
		<div class="display-total">bill: ${{subTotal}}</div> <br />

		<div class="min">$5</div>
		<input type="range" v-model='subTotal' min="5" max="300" />
		<div class="max">$300</div>
	</form>

	<figure class='big-face'>
		<div>{{face}}</div>
	</figure>

	<form class="feel" action="javascript:void()">
		<span>๐Ÿ˜ง</span>
		<input
			type="range"
			min="5" max="25" step="2"
			v-model='tipPercentage'
		/>
		<span>๐Ÿ˜ƒ</span>
	</form>

	<output class='outcome' v-if='subTotal'>
		<div class="sub-total">${{subTotal}}</div>
		<div class="tip">${{tip}}</div>
		<div class="to">${{totalWithTip}}</div>
		<div>{{tipPercentage}}%</div>
	</output>

</main>


<div class="thing">
	๐Ÿ˜กโ˜น๐Ÿ™๐Ÿ˜•๐Ÿ˜ถ๐Ÿ˜๐Ÿค”๐Ÿ™‚๐Ÿ˜„๐Ÿค—

	๐Ÿ˜๐Ÿ˜‹๐Ÿค—๐Ÿคญ๐Ÿค”๐Ÿคจ๐Ÿ˜
๐Ÿ˜‘๐Ÿ˜ถ๐Ÿ™„๐Ÿ˜ฌ๐Ÿ˜”๐Ÿคข๐Ÿ˜•๐Ÿ˜Ÿ
๐Ÿ™โ˜น๐Ÿ˜ฆ๐Ÿ˜ง๐Ÿ˜–๐Ÿ˜ ๐Ÿ˜ก๐Ÿ˜ž
๐Ÿคฎ๐Ÿ˜ƒ๐Ÿ˜€๐Ÿ˜„๐Ÿ™‚๐Ÿ˜Š
๐Ÿ˜ก๐Ÿ™๐Ÿ˜•๐Ÿ˜ฌ๐Ÿคญ๐Ÿ˜๐Ÿค”๐Ÿ™‚๐Ÿ˜„๐Ÿค—
</div>
              
            
!

CSS

              
                
html
	background: lightblue
	font-family: helvetica

body
	overflow: hidden
	
output
	display: block
	margin-top: 1rem
	span
		font-weight: bold

.field
	display: block
	margin-top: 1rem
	input
		padding: .5rem
		font-size: 18px
	&.tip
		opacity: .2

form
	margin-top: 1rem
	*
		display: inline-block
		vertical-align: middle
	span
		font-size: 40px


		
.price
	text-align: center
	width: 100%
	input
		width: 70vw
		max-width: 400px
	.display-total
		font-size: 50px
		
.feel
	text-align: center
	width: 100%
	input
		width: 70vw
		
.outcome
	border: 1px solid gray
	padding: .5rem
	font-size: 24px
	text-align: right
	max-width: 100px
	margin: 0 auto
	margin-top: 1rem
	.tip
		color: green
		
		
.thing
	font-size: 50px
	display: none
	
.big-face
	font-size: 200px
	display: flex
	flex-direction: row
	justify-content: center
	align-items: center
	margin-top: 2rem
              
            
!

JS

              
                
const options = ['๐Ÿ˜ก','๐Ÿ˜ฆ','๐Ÿ™','๐Ÿ˜','๐Ÿ˜ฌ','๐Ÿ™‚','๐Ÿ˜Š','๐Ÿ˜€','๐Ÿ˜ƒ','๐Ÿค—', '๐Ÿ˜'];
																// ๐Ÿ˜ƒ๐Ÿ˜€๐Ÿ˜„๐Ÿ™‚๐Ÿ˜Š
new Vue({
	el: '#vue-context',
	data: function() {
		return {
			excerciseNumber: 0,
			subTotal: '40',
			tipPercentage: '15',
			optionsData: options,
		};
	},
	computed: {
		tip() {
			let tipInDecimal = this.tipPercentage / 100;
			let rawTip = this.subTotal * tipInDecimal;
			return rawTip.toFixed(2);
		},
		totalWithTip() {
			let tip = Number(this.tip);
			let subTotal = Number(this.subTotal);
			return (subTotal + tip).toFixed(2);
		},
		face() {
			let x = (this.tipPercentage - 5)/2;
			return this.optionsData[x];
		},
	},
});

              
            
!
999px

Console