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 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

              
                <!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <!-- google font -->
  <link href="https://fonts.googleapis.com/css2?family=Lato:wght@400;700&family=Noto+Sans+TC:wght@400;500;700&display=swap" rel="stylesheet">
  <!-- Font-awsome -->
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/css/all.min.css">
  </link>
  <!-- animate -->
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.0/animate.min.css" />
  <!-- AOS -->
  <link rel="stylesheet" href="https://unpkg.com/aos@next/dist/aos.css" />
</head>

<body>
  <!-- https://codepen.io/ferry/pen/ZYVwxz -->
  <div class="wrap">
    <div class="container">
      <div class="menu">
        <h3 data-aos="fade-down-right" data-aos-delay="500" data-aos-duration="1000">Accordion Collapse with changing Icon</h3>
        <ul class="list" data-aos="flip-up" data-aos-delay="1000" data-aos-duration="1500">
          <li>
            <div class="item">
              <a href="#">Item #1</a>
              <i class="fas fa-plus-square fa-2x btn"></i>
            </div>
            <div class="pic pic1"></div>
          </li>
          <li>
            <div class="item">
              <a href="#">Item #2</a>
              <i class="fas fa-plus-square fa-2x btn"></i>
            </div>
            <div class="pic pic2"></div>
          </li>
          <li>
            <div class="item">
              <a href="#">Item #3</a>
              <i class="fas fa-plus-square fa-2x btn"></i>
            </div>
            <div class="pic pic3"></div>
          </li>
          <li>
            <div class="item">
              <a href="#">Item #4</a>
              <i class="fas fa-plus-square fa-2x btn"></i>
            </div>
            <div class="pic pic4"></div>
          </li>
          <li>
            <div class="item">
              <a href="#">Item #5</a>
              <i class="fas fa-minus-square fa-2x btn"></i>
            </div>
            <div class="pic pic5 default-img"></div>
          </li>
        </ul>
      </div>
      <div class="menu">
        <h3 data-aos="fade-down-left" data-aos-delay="500" data-aos-duration="1000">Accordion Collapse with Flipping Icon</h3>
        <ul class="list" data-aos="flip-down" data-aos-delay="1000" data-aos-duration="1500">
          <li>
            <div class="item">
              <a href="#">Item #1</a>
              <i class="fas fa-arrow-alt-circle-up fa-2x default-flip"></i>
            </div>
            <div class="pic pic6 default-img"></div>
          </li>
          <li>
            <div class="item">
              <a href="#">Item #2</a>
              <i class="fas fa-arrow-alt-circle-down fa-2x trigger"></i>
            </div>
            <div class="pic pic7"></div>
          </li>
          <li>
            <div class="item">
              <a href="#">Item #3</a>
              <i class="fas fa-arrow-alt-circle-down fa-2x trigger"></i>
            </div>
            <div class="pic pic8"></div>
          </li>
          <li>
            <div class="item">
              <a href="#">Item #4</a>
              <i class="fas fa-arrow-alt-circle-down fa-2x trigger"></i>
            </div>
            <div class="pic pic9"></div>
          </li>
          <li>
            <div class="item">
              <a href="#">Item #5</a>
              <i class="fas fa-arrow-alt-circle-down fa-2x trigger"></i>
            </div>
            <div class="pic pic10"></div>
          </li>
        </ul>
      </div>
    </div>
    <div class="practice">
      <div class="group">
        <input type="text" class="text" placeholder="Input Data">
        <input type="submit" class="send" value="Add">
      </div>
      <ul class="misson"></ul>
    </div>
  </div>
</body>

</html>
              
            
!

CSS

              
                * {
  padding: 0;
  margin: 0;
  list-style: none;
  line-height: 1.5em;
  letter-spacing: 0.1em;
  box-sizing: border-box;
  font-family: "Lato", "Noto Sans TC", sans-serif;
}

a {
  text-decoration: none;
  color: #fff;
}

body {
  width: 100%;
  height: 100%;
  background-color: #455a64;
}

.wrap {
  max-width: 1024px;
  margin: 0 auto;
}

.container {
  display: flex;
  justify-content: space-around;
}

.menu {
  width: 45%;
}

.menu h3 {
  text-align: center;
  font-size: 20px;
  color: #fff;
  padding: 10% 0 5% 0;
  border-bottom: 2px solid #fff;
}

.list {
  padding: 7% 0;
  color: #fff;
}

.list li .item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3% 2%;
  background-color: #009688;
  border-bottom: 2px solid #fff;
  position: relative;
}

.list li:first-child .item {
  border-radius: 5px 5px 0 0;
}

@media (max-width: 768px) {
  .container {
    display: block;
  }

  .menu {
    width: 90%;
    margin: 0 auto;
  }
}

.btn,
.trigger,
.default-flip {
  cursor: pointer;
  transition: 0.5s;
}

.trigger.active {
  transform: scaleY(-1);
}

.default-flip.change {
  transform: scaleY(-1);
}

.pic {
  width: 100%;
  padding: 20% 0;
  background-position: center center;
  background-size: cover;
  background-repeat: no-repeat;
  display: none;
}

.default-img {
  display: block;
}

.pic1 {
  background-image: url("http://michael-ferry.com/assets/accordion1.jpg");
}

.pic2 {
  background-image: url("http://michael-ferry.com/assets/accordion2.jpg");
}

.pic3 {
  background-image: url("http://michael-ferry.com/assets/accordion3.jpg");
}

.pic4 {
  background-image: url("http://michael-ferry.com/assets/accordion4.jpg");
}

.pic5 {
  background-image: url("http://michael-ferry.com/assets/accordion5.jpg");
  border-radius: 0 0 5px 5px;
}

.pic6 {
  background-image: url("http://michael-ferry.com/assets/accordion6.jpg");
}

.pic7 {
  background-image: url("https://unsplash.com/photos/eWBseWsTEpA/download");
}

.pic8 {
  background-image: url("https://unsplash.com/photos/26-lAP0XprM/download");
}

.pic9 {
  background-image: url("https://unsplash.com/photos/xVHr4B1WApk/download");
}

.pic10 {
  background-image: url("https://ununsplash.imgix.net/photo-1417870839255-a23faa90c6b0?fit=crop&fm=jpg&h=700&q=75&w=1050");
  border-radius: 0 0 5px 5px;
}

.practice {
  width: 50%;
  margin: 0 auto;
}

.practice .group {
  display: flex;
  justify-content: center;
}

.group .text {
  width: 35%;
  padding: 2%;
  background-color: #009688;
  border: none;
  outline: none;
  border-radius: 5px 0 0 5px;
}

.group .text::placeholder {
  color: #fff;
}

.group .send {
  width: 15%;
  border: none;
  outline: none;
  background-color: #fff;
  color: #009688;
  font-weight: bold;
  border-radius: 0 5px 5px 0;
  cursor: pointer;
}

.misson {
  width: 50%;
  margin: 5% auto;
}

.misson li {
  padding: 3%;
  background-color: #009688;
  border-bottom: 2px solid #fff;
}

.misson li:first-child {
  border-radius: 5px 5px 0 0;
}

.misson li a {
  margin-right: 5%;
}

@media (max-width: 768px) {
  .practice {
    width: 100%;
  }

  .group .text {
    width: 40%;
  }

  .group .send {
    width: 20%;
  }

  .misson {
    width: 60%;
  }
}

              
            
!

JS

              
                (function () {
  //JQuery
  $(".btn").on("click", function () {
    $(this).toggleClass("fa-plus-square");
    $(this).toggleClass("fa-minus-square");
    $(this)
      .parent()
      .parent()
      .siblings()
      .find("i")
      .removeClass("fa-minus-square");
    $(this).parent().parent().siblings().find("i").addClass("fa-plus-square");
    $(this).parent().siblings(".pic").slideToggle(500);
    $(this).parent().parent().siblings().find(".pic").slideUp(500);
  });
  $(".trigger").on("click", function () {
    $(this).toggleClass("active");
    $(this).parent().parent().siblings().find(".trigger").removeClass("active");
    $(this).parent().siblings(".pic").slideToggle(500);
    $(this).parent().parent().siblings().find(".pic").slideUp(500);
    $(".default-flip").addClass("change");
  });
  $(".default-flip").on("click", function () {
    $(this).removeClass("active");
    $(this).toggleClass("change");
    $(this).parent().siblings(".pic").slideToggle(500);
    $(this).parent().parent().siblings().find(".pic").slideUp(500);
    $(".trigger").removeClass("active");
  });
  // AOS
  AOS.init({
    // Global settings:
    disable: false, // accepts following values: 'phone', 'tablet', 'mobile', boolean, expression or function
    startEvent: "DOMContentLoaded", // name of the event dispatched on the document, that AOS should initialize on
    initClassName: "aos-init", // class applied after initialization
    animatedClassName: "aos-animate", // class applied on animation
    useClassNames: false, // if true, will add content of `data-aos` as classes on scroll
    disableMutationObserver: false, // disables automatic mutations' detections (advanced)
    debounceDelay: 50, // the delay on debounce used while resizing window (advanced)
    throttleDelay: 99, // the delay on throttle used while scrolling the page (advanced)

    // Settings that can be overridden on per-element basis, by `data-aos-*` attributes:
    offset: 120, // offset (in px) from the original trigger point
    delay: 0, // values from 0 to 3000, with step 50ms
    duration: 400, // values from 0 to 3000, with step 50ms
    easing: "ease", // default easing for AOS animations
    once: true, // whether animation should happen only once - while scrolling down
    mirror: false, // whether elements should animate out while scrolling past them
    anchorPlacement: "top-bottom" // defines which position of the element regarding to window should trigger the animation

    // 基本的AOS參數設定值:
    // offset: 120, // 以像素(px)為單位,水平移動
    // delay: 0, //延遲時間,範圍:0~ 3000
    // duration: 400, //動畫時間,範圍:0~ 3000
    // easing: ‘ease’, // 動畫速率效果
    // once: false, // 是否重複觸發動畫
    // mirror: false, // 是否超過滾動範圍時,做移出的動畫效果
    // anchorPlacement: ‘top - bottom’, // 滾動方向觸發動畫,預設由上到下
  });

  //JaveScript ToDoList
  let misson = document.querySelector(".misson");
  let send = document.querySelector(".send");
  //字串轉數字
  let data = JSON.parse(localStorage.getItem("listData")) || [];

  function addData() {
    // console.log('test click');
    let text = document.querySelector(".text").value;
    // console.log(text);
    if (text == "") {
      alert("Please Input Data!!!");
      return;
    }
    let todo = {
      item: text
    };
    // console.log(todo);
    data.push(todo);
    // console.log(data);

    //數字轉字串
    localStorage.setItem("listData", JSON.stringify(data));
    updateData(data);
  }

  function updateData(items) {
    let len = items.length;
    // console.log(num);
    let str = "";
    for (let i = 0; i < len; i++) {
      str += `<li><a href="#" data-index="${i}"> X </a>${items[i].item}</li>`;
    }
    misson.innerHTML = str;
    reset();
  }

  function deleteData(e) {
    e.preventDefault();
    let target = e.target.nodeName;
    // console.log(target);
    let index = e.target.dataset.index;
    // console.log(index);
    if (target !== "A") {
      return;
    }
    data.splice(index, 1);
    localStorage.setItem("listData", JSON.stringify(data));
    updateData(data);
  }

  function reset() {
    document.querySelector(".text").value = "";
  }
  send.addEventListener("click", addData, false);
  misson.addEventListener("click", deleteData, false);
  updateData(data);
})();

              
            
!
999px

Console