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

              
                .page-container
	.header
	.body
		button#open 弹出
		.notifications#notifications
				
              
            
!

CSS

              
                @keyframes toggleShow
	0%
		height: 0
		opacity: 0
	100%
		opacity: 1
		height: 106px

@keyframes notificationHide
	0%
		opacity: 1
	90%
		opacity: 1
	100%
		opacity: 0
	0%
		height: 100%
		margin-top: 16px
	90%
		height: 100%
		margin-top: 16px
	100%
		height: 0
		margin-top: 0px !important
	0%
		margin-top: 16px
	90%
		margin-top: 16px
	100%
		margin-top: 0px
		
html, body
	margin: 0
	height: 100%
	width: 100%
	display: flex
	justify-content: center
	align-items: center
	background-color: #222
.page-container
	height: 100%
	width: 100%
.header
	height: 200px
	width: 100%
.body
	height: 4000px
	width: 100%
.notifications
	position: fixed
	z-index: 1
	top: 0
	right: 0
	margin-top: 8px
	max-height: 100vh
	overflow: hidden
	padding: 0 0 12px 12px
	.notification
		overflow: hidden
		position: relative
		right: 0
		padding: 16px 24px
		background-color: #fff
		height: 106px
		width: 385px
		border-radius: 4px
		line-height: 1.5
		box-shadow: 0 4px 12px rgba(#000, 0.15)
		animation: toggleShow .15s ease-out
		.notification-body
			display: flex
			flex-direction: column
			.notification-header
				display: flex
				margin-bottom: 4px
				.notification-icon
					display: flex
					justify-content: center
					align-items: center
					height: 24px
					width: 24px
					margin-left: 4px
					display: flex
					justify-content: center
					align-items: center
				.notification-title
					height: 24px
					padding: 0 24px
					font-size: 16px
					line-height: 24px
					color: rgba(0, 0, 0, 0.85)
					display: inline-block
					overflow: hidden
			.notification-content
				margin-left: 48px
				font-size: 14px
				line-height: 1.5
				color: rgba(0, 0, 0, 0.65)
	.notification-hidden
		margin-top: 16px
		margin-right: 16px
		animation: notificationHide 3s ease forwards
		
	
              
            
!

JS

              
                const open = document.getElementById("open");
const notifications = document.getElementById("notifications");
const svg = `<svg width="24" height="24" viewBox="0 0 24 24"><path d="M18.71,19.5C17.88,20.74 17,21.95 15.66,21.97C14.32,22 13.89,21.18 12.37,21.18C10.84,21.18 10.37,21.95 9.1,22C7.79,22.05 6.8,20.68 5.96,19.47C4.25,17 2.94,12.45 4.7,9.39C5.57,7.87 7.13,6.91 8.82,6.88C10.1,6.86 11.32,7.75 12.11,7.75C12.89,7.75 14.37,6.68 15.92,6.84C16.57,6.87 18.39,7.1 19.56,8.82C19.47,8.88 17.39,10.1 17.41,12.63C17.44,15.65 20.06,16.66 20.09,16.67C20.06,16.74 19.67,18.11 18.71,19.5M13,3.5C13.73,2.67 14.94,2.04 15.94,2C16.07,3.17 15.6,4.35 14.9,5.19C14.21,6.04 13.07,6.7 11.95,6.61C11.8,5.46 12.36,4.26 13,3.5Z"></path></svg>`;
const notificationHtml = `<div class="notification">
        								<div class="notification-body">
											 <div class="notification-header">
												<div class="notification-icon">
												${svg}
												</div>
												<div class="notification-title">Notification Title</div>
											 </div>
											 <div class="notification-content"> 
												This is the content of the notification.
											 </div>
										  </div>
      						  </div>`

const createElementByString = _html => {
	const container = document.createElement('div');
	container.classList.add('notification-hidden');
	container.innerHTML = _html;
	return container;
}

open.addEventListener('click', () => {
	console.log(notifications)
	const newNotifications = createElementByString(notificationHtml);
	notifications.appendChild(newNotifications);
})
              
            
!
999px

Console