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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                img#cat(src="https://i.pinimg.com/originals/f1/af/e9/f1afe96b867d441675237ac7e3a0f60a.png", alt="")
#cross
.title 
  h2 To Do List
#mylist
  .top
    #title
     input#titleInput(placeholder="My List...")
     
  .bottom 
    #itemsWrapper
      .item
    #addNewItemsWrapper
        input#addNewItemsInput(type='text')
        #addItembtn
              
            
!

CSS

              
                *
  // border: solid 1px black
  font-family: 'Hind Siliguri',微軟正黑體
  box-sizing: border-box
  position: relative
  outline: none
  margin: 0


$color_yellow: #FFE5C4
$color_bright_yellow: #FCE9D4
$color_grey: #999999
$color_red: #F67E7D

html,body
  width: 100%
  height: 100%
  background-color: $color_yellow
  overflow: hidden

#cat
  width: 500px
  position: absolute
  left: 50%
  // transform: translateX(-50%)
  bottom: 0px
#cross
  position: absolute
  &:before,&:after
    content: " "
    display: block
    width: 60px
    height: 15px
    background-color: #fff
    position: absolute
    left: 50%
    top: 50%
    transform: translate(-50%,-50%) rotate(45deg)
  &:after
    transform: translate(-50%,-50%) rotate(-45deg)
    overflow: hidden
  
  
.title
  font-size: 30px
  color: $color_grey
  left: 650px
  top: 170px
  writing-mode: vertical-rl
  
#mylist
  width: 360px
  left: 300px
  top: 10px
#titleInput
  color: $color_grey
  width: 350px
  height: 48px
  padding: 10px
  background-color: $color_bright_yellow
  font-size: 22px
  font-weight: 600  
  border: 0px 
  border-radius: 7px
  box-shadow: 3px 4px 5px rgba(0,0,0,0.4)
#titleInput::placeholder
  color: rgba(63, 69, 95, .3)
  
.bottom
  width: 350px
  background-color: $color_yellow
  box-shadow: 3px 4px 5px rgba(0,0,0,0.4)
  margin-top: 10px
  border-radius: 7px

  
/* To do item */
#itemsWrapper
  padding: 4px
  // margin: 4px 0
  .item
    width: 100%
    padding: 4px 10px
    color: $color_grey
    position: relative
  input
    cursor: pointer
    position: relative
    visibility: hidden
    &:after
      border: 2px solid $color_grey
      border-radius: 50%
      content: ""
      display: block
      height: 14px
      width: 14px
      text-align: center
      visibility: visible
      transition: all 100ms ease-in-out
      background-color: $color_yellow
    &:checked:after
      border: 2px solid $color_red
      color: $color_yellow
      font-size: 16px
      border-radius: 50%
      content: "✔"
      line-height: 15px
      background-color: $color_red
      animation: bounce 100ms ease-in-out forwards
  .itemInner
    // padding: 4px 0
    display: flex
    align-items: center
    font-size: 20px
  .itemInner p
    margin-top: 6px
    padding-left: 10px
    pointer-events: none
  .fa-trash
    pointer-events: none
    color: $color_grey
    font-size: 16px
    margin-top: 6px
  .removeItemBtn 
    position: absolute
    right: 4px
    background: transparent
    border: 0
    cursor: pointer
    opacity: 0
  .far
    margin-right: 4px
    font-size: 16px
    cursor: pointer
  
    
  
/* Add a new item section */
#addNewItemsWrapper
  width: 100%
  position: relative
  display: flex
  align-items: center
  #addNewItemsInput
    width: 100%
    height: 45px
    font-size: 18px
    font-weight: 500
    border-radius: 7px
    color: $color_grey
    border: 0px 
    padding: 12px 30px 12px 10px
    margin: 10px 10px
    background-color: $color_yellow
    box-shadow: 3px 4px 5px rgba(0,0,0,0.4)
  #addItembtn
    cursor: pointer
    position: absolute
    &:before,&:after
      content: " "
      display: block
      position: absolute
      left: 310px
      width: 16px
      height: 3.5px
      background-color: $color_grey
      border: 0
      border-radius: 7px
      transition-duration: 0.3s
    &:after
      transform: rotate(-90deg)
    &:hover
      &:before
        transform: rotate(90deg)
      &:after
        transform: rotate(0deg)
  


  
  
    
              
            
!

JS

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

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


/* Add a new item */
$("#addItembtn").on("click", (e) => {
  if ($("#addNewItemsInput").val() == "") {
    gsap.to("#addNewItemsInput", .1, {x: -4})
    gsap.to("#addNewItemsInput", .1, {delay: .1, x: 4})
    gsap.to("#addNewItemsInput", .1, {delay: .2, x: -4})
    gsap.to("#addNewItemsInput", .1, {delay: .3, x: 4})
    gsap.to("#addNewItemsInput", .1, {delay: .4, x: 0})
  } else {
    const newItemInput = $("#addNewItemsInput").val()
  
  $(".item").append(
    `<div class="itemInner">
      <input type="checkbox" />
      <label for="ckeckbox"></label>  
      <p>${newItemInput}</p>
      <button class="removeItemBtn">
      <i class="fas fa-trash"></i>
      </button>
     </div>`)
  
  $("#addNewItemsInput").val("")
  
  const newItem = e.target

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


/* Remove item */
$(".item").on("click", ".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})
})


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


$(".item").on("click", (e) => {
  const i = e.target
  const completedItem = e.target.parentElement
  const text = completedItem.getElementsByTagName('p')
  $(text).css({"text-decoration": "line-through"})
})




$(window).mousemove(function(evt){
  var x = evt.pageX;
  var y = evt.pageY;
  console.log(x+","+y);
  
  $("#cross").css("left",x+"px");
  $("#cross").css("top",y+"px")
  
  if (x < $(window).width()/2 -50){ $("#cat").attr("src","https://i.pinimg.com/originals/1f/7f/1a/1f7f1abe4af37302063307bb4af453cf.png")
  }
  if (x > $(window).width()/2 +50){    $("#cat").attr("src","https://i.pinimg.com/originals/c2/c9/93/c2c993655f7c290e3071df05169a92d6.png")
  }
  if ( Math.abs(x - $(window).width()/2) <50){    $("#cat").attr("src","https://i.pinimg.com/originals/68/39/f3/6839f3b38705fc2b6c232b488d65f50a.png")
  }
  
  if (x < $(window).width()/2 -50 && y<$(window).height()/2){
    $("#cat").attr("src","https://i.pinimg.com/originals/f1/af/e9/f1afe96b867d441675237ac7e3a0f60a.png")
  }
  if (x > $(window).width()/2 +50 && y<$(window).height()/2){
    $("#cat").attr("src","https://i.pinimg.com/originals/20/8f/2b/208f2ba12067a8498221f090abff54b2.png")
  }
  
  
});
              
            
!
999px

Console