cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

            
              <div id="app">
  
  <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/28963/vue-post-photo.jpg" alt="" class="main-photo">
  <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/28963/vue-main-profile.jpg" alt="" class="main-profile">
  
  <main class="main-info">
    <span class="name">Julia Delfina</span>
    <h3>Text that she's saying.</h3>
  </main>
  
  <ul>
    <li is="app-comment" v-for="comment in comments" :key="comment" :comment="comment"></li>
  </ul>
  
  <br>
  
  <label for="stuff">Write a comment:</label>
  <input type="text" id="stuff" v-model="newComment" @keyup.enter="submitComment">
  
  
</div>

<script type="text/x-template" id="commentTemplate">
  <li>
    <img :src="comment.authorImg" class="post-img">
    <small>{{ comment.author }}</small>
    <p class="post-comment">{{ comment.text }}</p>
  </li>
</script>
            
          
!
            
              body {
  font-family: 'Playfair Display', serif;
  background: #888;
}

#app {
  background: #212222;
  color: #fff;
  letter-spacing: 0.04em;
  text-align: center;
  margin: 60px;
  width: 370px;
  margin: 0 auto;
  display: table;
  padding: 20px;
  line-height: 1.4em;
}

.name {
  color: #ccc;
}

small {
  color: #bbb;
  font-size: 10px;
}

h3 {
  margin: 5px 0 4px;
}

.main-photo {
  width: 300px;
}

.main-profile {
  float: left;
  border: 3px solid white;
  margin: -25px 0 0 20px;
  position: relative;
  width: 80px;
}

.main-info {
  float: left;
  padding: 10px 20px;
  text-align: left;
  margin-bottom: 15px;
  &:after {
    content: "";
    display: table;
    clear: both;
  }
}

li {
  list-style: none outside none;
  text-align: left;
  padding: 10px 0;
  border-bottom: 1px solid #555;
}

ul {
  margin: 0;
  padding: 0 35px;
}

hr {
  margin: 25px 0 0 32px;
  width: 300px;
  border-top: 0;
  border-bottom: 1px solid #555;
}

input {
  font-family: 'Playfair Display', serif;
  width: 280px;
  margin: 30px 0;
  padding: 8px 10px;
  outline: 0;
}

.post-img {
  border: 3px solid white;
  float: left;
  margin: 0 15px 0 -2px;
  transition: 0.3s all ease;
}

.post-comment {
  margin: 0 0 5px 0;
}

            
          
!
            
              Vue.component("AppComment", {
  template: "#commentTemplate",
  props: ["comment"]
});

const newCommentUrl =
  "https://s3-us-west-2.amazonaws.com/s.cdpn.io/28963/v-skull.jpg";
const comments = [
  {
    text: "Looks great Julianne!",
    author: "Robin Rendle",
    authorImg: "https://s3-us-west-2.amazonaws.com/s.cdpn.io/28963/v-coffee.jpg"
  },
  {
    text: "I love the Sea",
    author: "Miriam Suzanne",
    authorImg: "https://s3-us-west-2.amazonaws.com/s.cdpn.io/28963/v-miriam.jpg"
  },
  {
    text: "Where are you?",
    author: "Geoff Graham",
    authorImg: "https://s3-us-west-2.amazonaws.com/s.cdpn.io/28963/v-geoff.jpg"
  }
];

new Vue({
  el: "#app",
  data: {
    newComment: "",
    comments: comments
  },
  methods: {
    submitComment() {
      // regular js!!!
      this.comments.push({
        text: this.newComment,
        author: "Chris Coyier",
        authorImg: newCommentUrl
      });
      this.newComment = "";      
    }
  },
  
  watch: {
    comments() {
      console.log("changed");
    }
  }
  
});

            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console