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

              
                // component
.w-full
	.flex.items-center.justify-center.h-screen
		.mx-24.bg-sky-400.rounded.shadow-lg
			.px-12.py-6
				.text-center
					h1.font-normal.text-3xl.text-grey-darkest.my-1.w-full 輸入「letswrite」即可執行
					p.my-2 筆記文:
						a.text-white.underline(href="https://www.letswrite.tw/custom-event/") Let's Write
					.w-full.text-center
						.max-w-sm.mx-auto.p-1.pr-0.flex.items-center
							input#input.flex-1.appearance-none.rounded.shadow.p-3.text-grey-dark.mr-2(type='text', class='focus:outline-none', placeholder="letswrite")
							button#button.appearance-none.bg-sky-700.text-white.text-base.font-semibold.tracking-wide.uppercase.p-3.rounded.shadow(type='button' class='hover:bg-sky-900') 確認

              
            
!

CSS

              
                
              
            
!

JS

              
                const input = document.getElementById('input');
const btn = document.getElementById('button');

btn.addEventListener('click', e => {
	let value = input.value;
	if(value === 'letswrite') {
		
		// 註冊客製事件
		let eventDemo = new CustomEvent('letswrite', {
			detail: new Date()
		})
		document.dispatchEvent(eventDemo)
	
	}
})

// 監聽客製事件
document.addEventListener('letswrite', e => {
	alert(e.detail)
})
              
            
!
999px

Console