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 Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

HTML

              
                <div class="shoppingList">
	<img src="https://image.flaticon.com/icons/svg/34/34568.svg" alt="trolly">
	<h1>My Shopping List</h1>
	<div class="listContainer">
		<p id="text"></p>
		<ul></ul>
	</div>
	
</div>
<div class="formContainer">
	<form class='addItemsForm'>
		<input id="itemInput" type="text" name="add" placeholder="add item to your list..">
		<input id="addtolistBtn" type="submit" value="Add to List">
		<input id="clearItems" type="submit" value="Clear List">
	</form>
	<button class="addBtn">Add Item</button>
</div>


              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=Architects+Daughter|Lalezar');

* {
	box-sizing: border-box;
}

html,body {
	background-color: #2552AC;
	color: white;
	font-family: 'Architects Daughter', cursive;
	line-height: 1.5;
}

.shoppingList {
	background-color: #F1F4F6;
	color: black;
	width: 70%;
	margin: 3em auto 0;
	padding: 2em 0 0;
	text-align: center;
	
	img {
		display: block;
		margin: 0 auto;
		padding: .5em 0;
		width: 50px;
	}
	h1, p {
		padding: .5em 1em 1em;
		margin: 0;
	}
	ul {padding: 0;}
	li {
		list-style: none;
		padding: 1em 0;
		margin: 0;
		text-align: center;
		font-family: 'Architects Daughter', cursive;
		font-size: 18px;
	}
	
	li:nth-child(even) {
		background-color:#5AC8D8;
	}
}

.addItemsForm {
	width: 70%;
	height: 20%;
	margin: 0 auto;
	display: none;
	
	input[type='text'] {
		padding: 2em;
		margin: 0;
		width: 100%;
		border: none;
		display: block;
	} 
}

#addtolistBtn { 
	border: none;
	font-family: 'Lalezar', cursive;
	font-size: 1.5rem;
	background-color: #597FCA;
	padding: 1em;
	color: white;
	width: 100%;
	transition: all .2s ease-in;
	&:hover {
		background-color: darken(#597FCA, 10%);
	}
}

.addBtn{
	@extend #addtolistBtn;
	margin: 0 auto;
	display: block;
	padding: 1em 0;
	font-size: 1.5rem;
	width: 70%;
}

#clearItems {
	@extend #addtolistBtn;
	margin: .5em auto;
}

.hide {
	display: none;
}

.show {
	display: block;
}
              
            
!

JS

              
                let addItemBtn = document.querySelector('.addBtn');
let addItemsForm = document.querySelector('.addItemsForm');
let listContainer = document.querySelector('.listContainer');
let listContainerUl = document.querySelector('.listContainer ul');
let text = document.querySelector('#text');
const removeShopping = document.querySelector('#clearItems');
// Shopping list ----
let shoppingList = JSON.parse(localStorage.getItem('shopping')) || [];


// Add items Function =====
function addItems(items){
	listContainerUl.innerHTML = items.map((item) => {
		return `
				<li>${item}</li>
				`;
	}).join('');
}

// Delete Local Storage ======
function clearItems(e){
	e.preventDefault();
	// Empty Local Storage ====
	localStorage.clear();
	// Empty Array ======
	shoppingList = [];
	// Empty UL ====
	listContainerUl.innerHTML = '';
	// Add back in text =====
	text.innerHTML = 'Your Shopping list is empty, add something...';
}

// Add Item Function ========
function addItem(){
	addItemBtn.innerHTML = 'loading...';
	setTimeout(function(){	
		// hiding button
		addItemBtn.classList.add("hide");
		// showing form
		addItemsForm.classList.add("show");
	}, 500);
}	

// Add item to list btn =======
	$('#addtolistBtn').on('click', function(e){
		e.preventDefault();
		text.innerHTML = '';
		var item = $('input').val();
		if(item === '') return;
		
		// Add item to Array.
		shoppingList.push(item);
		// Set item in LocalStorage
		localStorage.setItem('shopping', JSON.stringify(shoppingList));
		addItems(shoppingList);
		$('#itemInput').val('');

	});


// Call addItems Function =====
addItems(shoppingList);

addItemBtn.addEventListener('click', addItem);
removeShopping.addEventListener('click', clearItems); 
              
            
!
999px

Console