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 includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

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

              
                
<header>
	<h1>Calculate Tip!</h1>
</header>

<main id='vue-context'>

	<form class='price' action='javascript:void()'>
		<h2 class='display-total'>bill: ${{subTotal}}</h2> <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='tip'>TIP = ${{tip}}</div>
	</output>
	
	<output class='details' v-if='subTotal'>
		<div class='sub-total'>${{subTotal}}</div>
		<div class='tip'>${{tip}}</div>
		<div class='to'>TOTAL: ${{totalWithTip}}</div>
		<div>{{tipPercentage}}%</div>
	</output>

</main>


















<div class='thing'>
	<!-- just saving these here -->
	๐Ÿ˜กโ˜น๐Ÿ™๐Ÿ˜•๐Ÿ˜ถ๐Ÿ˜๐Ÿค”๐Ÿ™‚๐Ÿ˜„๐Ÿค—

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

CSS

              
                
html
	font-family: Sans-serif

body
	overflow: hidden
	min-height: 100vh
	background-color: lightblue
	background-image: linear-gradient(30deg, hsl(180, 100, 50%), hsl(3200, 100, 50%) )
	padding: 10px

header
	text-align: center
	font-size: 40px
	padding: 20px
	color: white

.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: 65vw
		max-width: 400px
	.display-total
		font-size: 30px
		
.feel
	text-align: center
	width: 100%
	input
		width: 45vw
		
output
	display: block
	margin-top: 1rem
	span
		font-weight: bold		

.outcome
	border: 1px solid gray
	padding: .5rem
	font-size: 24px
	text-align: right
	max-width: 200px
	margin: 0 auto
	margin-top: 1rem
	text-align: center
	.tip
		color: white

.details
	font-family: monospace
	font-size: 15px
	opacity: .6

.thing
	font-size: 50px
	display: none
	
.big-face
	font-size: clamp(150px, 20vw, 300px)
	display: flex
	flex-direction: row
	justify-content: center
	align-items: center
	margin-top: 2rem



              
            
!

JS

              
                
const options = ['๐Ÿ˜ก','๐Ÿ˜ฆ','๐Ÿ™','๐Ÿ˜','๐Ÿ˜ฌ','๐Ÿ™‚','๐Ÿ˜Š','๐Ÿ˜€','๐Ÿ˜ƒ','๐Ÿค—', '๐Ÿ˜'];
																// ๐Ÿ˜ƒ๐Ÿ˜€๐Ÿ˜„๐Ÿ™‚๐Ÿ˜Š// just some other 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 successNumber = (this.tipPercentage - 5)/2;
			return this.optionsData[successNumber];
		},
	},
});

              
            
!
999px

Console