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

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

              
                <!-- Import jQuery, FontAwesome Icons and Open Sans Font -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

<script src="https://kit.fontawesome.com/56942480bb.js" crossorigin="anonymous"></script>

<link href="https://fonts.googleapis.com/css2?family=Open+Sans:[email protected];600;700&display=swap" rel="stylesheet">

<!-- List wrapper -->
<div id="listWrapper">
  
  <!-- List title -->
  <div id="title">
    <input id="titleInput" type="text" placeholder="My List" maxlength="21">
    <i class="fa fa-pencil-alt"></i>
  </div>

  <div id="separator"></div>

  <!-- To do items -->
  <div id="itemsWrapper">
    <div class="item">
      <!-- New items are created here -->
    </div>
  </div>

  <!-- Add a new item -->
  <div id="addNewItemWrapper">
    <input type="text" id="addNewItemInput" maxlength="30">
    <button id="addNewItemBtn"><i class="fas fa-plus"></i></button>
  </div>
  
</div>
              
            
!

CSS

              
                * {
  box-sizing: border-box;
  outline: none;
}

/* Center the list */
body {
  margin: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #f3f5fc;
}

#listWrapper {
  background: white;
  border-radius: 9px;
  border: 1px solid #e7ecfb;
  box-shadow: 0 0 30px rgba(211, 220, 248, .3);
  padding: 30px;
}

/* List title */
#title {
  position: relative;
  display: flex;
  align-items: center;
}

#titleInput {
  font-family: "Open Sans", sans-serif;
  font-size: 24px;
  font-weight: 800;
  border: 1px solid transparent;
  border-radius: 9px;
  color: #666f99;
  padding: 9px 18px;
}

#titleInput::placeholder {
  color: rgba(63, 69, 95, .3);
}

/* List title pencil */
.fa-pencil-alt {
  font-size: 18px;
  border-radius: 50%;
  position: absolute;
  right: 24px;
  pointer-events: none;
  color: #a8baf0;
}

/* Separator */
#separator {
  margin: 12px 0;
  box-shadow: 0 12px 12px rgba(211, 220, 248, .3);
  border-top: 0;
  border-right: 0;
  border-left: 0;
  max-width: 100%;
  height: 10px;
}

/* To do items wrapper */
#itemsWrapper {
  padding: 8px 8px;
  margin: 12px 0;
}

/* To do item */
.item {
  width: 100%;
  font-size: 18px;
  font-family: "Open Sans", sans-serif;
  border-radius: 12px;
  border: 0;
  padding: 9px 12px;
  color: #3f455f;
  position: relative;
}

.itemInner {
  padding: 9px 0;
  display: flex;
  align-items: center;
  font-size: 16px;
}

.itemInner p {
  margin: 0;
  pointer-events: none;
}

/* Item buttons */
.fa-trash-alt {
  pointer-events: none;
  color: #a8baf0;
  font-size: 18px;
}

.removeItemBtn {
  position: absolute;
  right: 4px;
  background: transparent;
  border: 0;
  cursor: pointer;
  opacity: 0;
}

.fa-hand-point-right {
  color: #a8baf0;
  margin-right: 9px;
  font-size: 24px;
  cursor: pointer;
}

/* Add a new item section */
#addNewItemWrapper {
  width: 100%;
  position: relative;
  display: flex;
  align-items: center;
}

#addNewItemInput {
  width: 100%;
  font-family: "Open Sans", sans-serif;
  font-size: 16px;
  font-weight: 600;
  border: 0;
  border-radius: 9px;
  color: #666f99;
  padding: 12px 60px 12px 18px;
  background: #f3f5fc;
}

#addNewItemBtn {
  position: absolute;
  right: 0;
  height: 100%;
  padding: 0 18px;
  background: transparent;
  border: 0;
  color: #666f99;
  cursor: pointer;
  font-size: 18px;
}
              
            
!

JS

              
                /* Submit on Enter */
$("#addNewItemInput").on("keydown", (e) => {
  if (e.keyCode === 13) {
    $("#addNewItemBtn").click()
    $("#addNewItemInput").val("")
  }
})

$("#titleInput").on("keydown", (e) => {
  if (e.keyCode == 13) {
    $("#titleInput").blur();
  }
})

/* Add a new item */
$("#addNewItemBtn").on("click", (e) => {
  if ($("#addNewItemInput").val() == "") {
    gsap.to("#addNewItemInput", .1, {x: -4})
    gsap.to("#addNewItemInput", .1, {delay: .1, x: 4})
    gsap.to("#addNewItemInput", .1, {delay: .2, x: -4})
    gsap.to("#addNewItemInput", .1, {delay: .3, x: 4})
    gsap.to("#addNewItemInput", .1, {delay: .4, x: 0})
  } else {
    const newItemInput = $("#addNewItemInput").val()
  
  $(".item").append(
    `<div class="itemInner">
      <i class="far fa-hand-point-right"></i>
      <p>${newItemInput}</p>
      <button class="removeItemBtn">
       <i class="fas fa-trash-alt"></i>
      </button>
     </div>`)
  
  $("#addNewItemInput").val("")
  
  const newItem = e.target

  gsap.to(".itemsWrapper, .item", .3, {paddingBottom: 30, ease: Back.easeOut})
  gsap.to(".itemsWrapper, .item", .3, {delay: .15, paddingBottom: 8, y: 0, ease: Back.easeOut})
  }
})

/* Completed item line through */
$(".item").on("click", "i.fa-hand-point-right", (e) => {
  const handPoint = e.target
  const completedItem = e.target.parentElement
  const text = completedItem.getElementsByTagName('p')
  
  $(text).css({"text-decoration": "line-through"})
  gsap.to(handPoint, .3, {rotate: -30, transformOrigin: "center", ease: Back.easeOut})
  gsap.to(handPoint, .3, {delay: .15, rotate: 0, transformOrigin: "center", ease: Back.easeOut})
})

/* Remove item */
$(".item").on("click", "button.removeItemBtn", (e) => {
    const removeItem = e.target
    const itemInner = removeItem.parentElement    
    $(itemInner).remove()
  
  gsap.to(".itemsWrapper, .item", 0, {paddingBottom: 52})
  gsap.to(".itemsWrapper, .item", .3, {paddingBottom: 8, ease: Back.easeOut})
})

/* Edit list title animation */
gsap.set(".fa-pencil-alt", {opacity: 0, rotate: -180, transformOrigin: "center"})
gsap.set("#titleInput, #addNewItemInput", {border: "1px solid transparent", boxShadow: "0 0 0 rgba(211, 220, 248, .3)"})

$("#titleInput").on("mouseenter", () => {
    gsap.to(".fa-pencil-alt", .3, {rotate: 0, opacity: 1, transformOrigin: "center", ease: Back.easeOut})
})

$("#titleInput").on("mouseleave", () => {
  if ($("#titleInput").is(":focus")) {
    gsap.to(".fa-pencil-alt", .3, {rotate: 0, opacity: 1, transformOrigin: "center", ease: Back.easeOut})
  } else if (!($("#titleInput").is(":focus"))) {
    gsap.to(".fa-pencil-alt", .3, {rotate: -180, opacity: 0, transformOrigin: "center", ease: Back.easeOut})
  }
})

$("#titleInput").on("focus", () => {
  gsap.to(".fa-pencil-alt", .3, {rotate: 0, opacity: 1, transformOrigin: "center", ease: Back.easeOut})
  gsap.to("#titleInput", .3, {border: "1px solid #e7ecfb", boxShadow: "0 0 12px rgba(211, 220, 248, .3)"})
})

$("#titleInput").on("focusout", () => {
  gsap.to(".fa-pencil-alt", .3, {rotate: -180, opacity: 0, transformOrigin: "center", ease: Back.easeOut})
  gsap.to("#titleInput", .3, {border: "1px solid transparent", boxShadow: "0 0 12px rgba(211, 220, 248, 0)"})
})

/* Trash fade on item hover */
$(".item").on("mouseenter", ".itemInner", (e) => {
  const trashBtn = $(e.target.querySelector(".removeItemBtn"))
  gsap.to(trashBtn, .3, {opacity: 1})
})

$(".itemInner").on("mouseenter", ".removeItemBtn", (e) => {
  const trashBtn = e.target
  gsap.to(trashBtn, .3, {opacity: 1})
})

$(".innerItem").on("mouseleave", ".removeItemBtn", (e) => {
  gsap.to(trashBtn, .3, {opacity: 0})
})

$(".item").on("mouseleave", ".itemInner", (e) => {
  const trashBtn = $(e.target.querySelector(".removeItemBtn"))
  gsap.to(trashBtn, .3, {opacity: 0})
})

$(".itemInner").on("mouseleave", ".removeItemBtn", (e) => {
  const trashBtn = e.target
  gsap.to(trashBtn, .3, {opacity: 0})
})

/* Add a new item animation */
$("#addNewItemInput").on("focus", () => {
  gsap.to("#addNewItemInput", .3, {border: "1px solid #e7ecfb", boxShadow: "0 0 12px rgba(211, 220, 248, .3)"})
})

$("#addNewItemInput").on("focusout", () => {
  gsap.to("#addNewItemInput", .3, {border: "1px solid transparent", boxShadow: "0 0 12px rgba(211, 220, 248, 0)"})
})

$("#addNewItemBtn").on("mouseenter", () => {
  gsap.to(".fa-plus", .3, {rotate: 90, ease: Back.easeOut})
})

$("#addNewItemBtn").on("mouseleave", () => {
  gsap.to(".fa-plus", .3, {rotate: 0, ease: Back.easeOut})
})
              
            
!
999px

Console