Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ 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

Auto Save

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

              
                <link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,400;0,700;0,900;1,400;1,700&display=swap" rel="stylesheet">

<div id="list-container">

  <header id="todo-header">
    <h1>ToDo</h1>
  </header>

</div>

<div id="add-note" class="expanded">
  <button id="convert-layout">+</button>
</div>
              
            
!

CSS

              
                html {
  background-color: #d0d1ff;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
}

#list-container {
  background-color: #003049;
  width: 300px;
  min-height: 100px;
  border-radius: 2em 2em 1em 1em;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#add-note {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: none;
  margin: 0;
  padding: 0em 0.2em 0.2em 0.2em;
  text-align: center;
  border-radius: 0px 0px 30px 30px;
  background-color: #d62828;
}

#add-note #convert-layout {
  border: none;
  z-index: -100px;
  font-size: 2em;
  font-family: lato;
  font-weight: 900;
  text-align: center;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  margin-top: 5px;
  color: white;
  background-color: #d83e3e;
  transition: filter 0.1s linear;
  cursor: pointer;
}

#add-note button:hover {
  filter: brightness(120%);
}

#todo-header {
  text-align: left;
  font-family: lato;
  font-weight: 900;
  letter-spacing: 2px;
  color: white;
  display: inline-block;
  width: 100%;
  background-color: #d62828;
  border-radius: 1em 1em 0em 0em;
  box-sizing: border-box;
  padding-left: 1.5em;
  margin-bottom: 10px;
}

#todo-header h1 {
  margin: 0.2em 0em;
}

.card {
  width: 90%;
  min-height: 50px;
  font-family: lato;
  font-weight: 900;
  font-size: 1.5em;
  text-wrap: wrap;
  color: white;
  letter-spacing: 1px;
  background-color: #37b0ce;
  border-radius: 20px;
  margin-bottom: 15px;
  transition: filter 0.1s linear;
  display: flex;
  justify-content: center;
  text-align: center;
}

.chk {
  border: 2px solid #78dc76;
  width: 70px;
  border-radius: 20px 35px 35px 20px;
  background-color: #78dc76;
  cursor: pointer;
}

.del {
  border: 2px solid #e66f6f;
  width: 70px;
  border-radius: 35px 20px 20px 35px;
  background-color: #e66f6f;
  cursor: pointer;
}

.card:nth-child(2) {
  margin-top: 10px;
}

.card:last-child {
  margin-bottom: 20px;
}

.expanded input {
  border: none;
  margin: 0.5em;
  border-radius: 0.3em;
  font-size: 1.2em;
  padding: 0.4em;
  width: 200px;
}

.expanded #add-new-task {
  all: revert;
  height: 2em;
  width: 90%;
  font-weight: 900;
  font-family: lato;
  color: white;
  border: none;
  font-size: 1em;
  margin-bottom: 10px;
  border-radius: 0em 0em 1em 1em;
  background-color: #d83e3e;
}

              
            
!

JS

              
                let todoList = document.querySelector("#list-container");
let todoHeader = todoList.querySelector("#todo-header");

function createCard(text) {
  let card = document.createElement("div");
  card.classList.add("card");

  let p = document.createElement("p");
  p.append(text);
  card.appendChild(p);

  return card;
}

function delCard() {
  let card = this.parentElement;
  card.remove();
}

function chkText() {
  let text = this.parentElement.children[1];
  text.style["text-decoration"] = "line-through";

  text.style["text-decoration-color"] = "red";
}

function addCardHover() {
  let chkBtn = document.createElement("button");
  chkBtn.classList.add("chk");
  chkBtn.addEventListener("click", chkText);
  chkBtn.innerHTML = "&#10003;";

  let delBtn = document.createElement("button");
  delBtn.classList.add("del");
  delBtn.addEventListener("click", delCard);
  delBtn.innerHTML = "&#10007;";

  this.prepend(chkBtn);
  this.append(delBtn);

  this.style["justify-content"] = "space-between";
  this.style["background-color"] = "#498a99";
}

function delCardHover() {
  let [a, b, c] = this.children;
  a.remove();
  c.remove();
  this.style["justify-content"] = "center";
  this.style["background-color"] = "#37B0CE";
}

function generateTask() {
  let parent = this.parentElement;
  let inp = parent.children[0];
  let newCard = createCard(inp.value);
  newCard.addEventListener("mouseenter", addCardHover);
  newCard.addEventListener("mouseleave", delCardHover);
  todoList.append(newCard);
}

let convertButton = document.querySelector("#convert-layout");

function convertLayout() {
  let addTask = document.createElement("button");
  addTask.id = "add-new-task";
  addTask.innerText = "+";
  addTask.addEventListener("click", generateTask);
  addTask.addEventListener("click", convertBack);

  let newInp = document.createElement("input");
  newInp.type = "text";
  let container = this.parentElement;

  container.append(newInp);
  container.append(addTask);

  this.remove();
}

function convertBack() {
  let parent = this.parentElement;
  let input = parent.children[0];
  input.remove();
  this.remove();

  let convertButton = document.createElement("button");
  convertButton.id = "convert-layout";
  convertButton.innerText = "+";
  convertButton.addEventListener("click", convertLayout);
  parent.append(convertButton);
}

convertButton.addEventListener("click", convertLayout);

              
            
!
999px

Console