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

              
                <div id="overlay">
 <div><h2>tinilista TIPS</h2>
<p>You can: <br>- Add item to list<br>- Cross over finished task<br>
    - Save your list for later<br>- Delete unwanted tasks. <br>(Click anywhere to exit this window).</p>
</div>
</div>
<div id="todo">
    <div>
    <header>
        <h1>tiniLista</h1>
        <input type="text" placeholder="Add new item">        
    </header>
    <div class="scrollable">
        <ul class="lista">

        </ul>  
    </div>
    </div>

    <div id="buttons">
        <button class="save"><i class="material-icons">save</i></button>
        <button class="clear"><i class="material-icons">clear</i></button>
        <button class="tips"><i class="material-icons">help</i></button>
    </div>

</div>
<footer>&copy;2019 <a href="http://sarahvgomez.com">Sarah Gomez</a></footer>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=Caveat|Major+Mono+Display');
*, *::before, *::after{
    box-sizing: border-box;
}
body{
background: #fbf0af;
font-family: Arial, Helvetica, sans-serif;
}
footer{
    font-size: 0.8rem;
    color: #f7c115;
    text-align: center;
    opacity: 0.5;
}
a{
    text-decoration: none;
    font-weight: bold;
}
a:visited{
    color: #f7c115;  
}

#todo{
    display:flex;
    flex-direction: column;
    justify-content: space-between;
    width: 95%;
    height: 80vh;
    margin: 2rem auto 1.3em;
    border: 1.5px solid #f7c115;
    border-radius: 10px;
    background: white;
    padding: 1rem;
    -webkit-box-shadow: 7px 8px 29px 0px rgba(231,166,26,0.5);
    -moz-box-shadow: 7px 8px 29px 0px rgba(231,166,26,0.5);
    box-shadow: 7px 8px 29px 0px rgba(231,166,26,0.5);
}
.checked{
    text-decoration: line-through;
    font-style: italic;
    color: gray;
}
li{
    cursor: pointer;
    font-family: 'Caveat';
    font-size: 1.5rem;
    border-bottom: 0.5px solid #eeebeb;
}
h1,h2{
    text-align: center;
    color: #f7c115;
    font-family: 'Major Mono display';
}
span{
    color: lightgray;
    opacity: 0;
    vertical-align: middle;
     float: right;
}
li:hover > span{
    opacity: 1;
    transition: 0.7s opacity;
}
input[type=text]{
    width: 100%;
    height: 2rem;
    padding: 0.5rem;
    border:0;
    border-radius: 5px;
    background: #f3f2f2;
    font-size:1.2rem;
    font-family: 'Caveat';
    text-align: center;
}
button{
    background: none;
    border: 0;
    cursor: pointer;
    color: #808080;
}
button:hover{
    color: #f7c115;
}
button:active{
    transform: scale(1.2);
}
#buttons{
    margin: 0 auto;
    width: 80%;
    display:flex;
    justify-content: center;
}
ul {
    list-style-type: none;
    margin-left: -15px;
}
  
ul li:before {
    color: #f7c115;
    content: '\2014';
    position: relative;
    margin-left: -20px;
  }
.scrollable{
    overflow: auto;
    height:190px;
}
#overlay{
    position: fixed;
    display: none;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0,0,0,0.7);
    z-index: 2;
    cursor: pointer;
  }
  #overlay > div{
    color: white;
    font-size: 0.9rem;
    text-align: center;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}
              
            
!

JS

              
                // declaring variables
var input = document.querySelector("input[type= 'text']");
var lista = document.querySelector("ul");
var container = document.querySelector("div");


function deleteClick(){
    var spans = document.querySelectorAll('span');
    for(let span of spans){
        span.addEventListener("click", function(){
            span.parentElement.remove();
            // event.stopPropagation();
        });
    }
}

// adding new items to the list
input.addEventListener("keypress",function(pressedKey){
    if(pressedKey.which === 13){
        // create a new item with icon wrapped in span
        var iteme = document.createElement("li");
        var addSpan = document.createElement("span");
        var icon = document.createElement("i");
        icon.innerHTML = "clear";

        var newItem = this.value;
        this.value = " ";

        icon.classList.add('material-icons'); // add material Icons to span
        addSpan.append(icon);

        lista.appendChild(iteme).append(newItem, addSpan);

        deleteClick();
    }
});

// strike through finished task
lista.addEventListener('click', function(ev){
    if(ev.target.tagName === "LI"){
        ev.target.classList.toggle('checked');
    }
},false
);

// button-menu functionality
var save = document.querySelector('.save');
var clear = document.querySelector('.clear');

save.addEventListener('click', function(){
    localStorage.setItem('tiniLista', lista.innerHTML);
});

function loadLista(){ //if there is anything stored in localStorage();
    if(localStorage.getItem('tiniLista')){
        lista.innerHTML = localStorage.getItem('tiniLista');
        deleteClick();
    }
}

clear.addEventListener('click', function(){
  lista.innerHTML = "";
  localStorage.removeItem('tiniLista', lista.innerHTML);
});


loadLista();
deleteClick();


var tips = document.querySelector(".tips");
tips.addEventListener('click', function(){
    document.getElementById("overlay").style.display ="block";
});
overlay.addEventListener('click', function(){
    document.getElementById("overlay").style.display ="none";
})

              
            
!
999px

Console