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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                <div id="vue">
  <main class="links">
    <a v-for="{title, link, span} of posts" :data-span="span" class="link" :href="link">{{title}}</a>
  </main>
</div>
              
            
!

CSS

              
                body {
  font-family: sans-serif;
  background: #eee;
}

.links {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  grid-auto-rows: min-content;
  grid-gap: 1rem;
  grid-auto-flow: dense;
}

.link {
  color: #111;
  background: white;
  border-radius: 5px;
  padding: 1rem;
  text-decoration: none;
  box-shadow: 0px 1px 1px 1px #ddd;
}

.link:hover {
  transform: scale(1.02);
}

.link[data-span = "1"] {
  grid-row: span 1
}

.link[data-span = "2"] {
  grid-row: span 2
}

.link[data-span = "3"] {
  grid-row: span 3
}

.link[data-span = "4"] {
  grid-row: span 4
}

.link[data-span = "5"] {
  grid-row: span 5
}
              
            
!

JS

              
                new Vue({
  el: "#vue",
  data: {
    postSourceUrl: 'https://www.reddit.com/r/todayilearned.json',
    posts: [],
    spanBreak: 100 // content length unit
  },
  methods: {
    getPosts: async function () {
      const data = (await (await fetch(this.postSourceUrl)).json()).data
      return [...data.children]
    },
    createPost: function (post) {
      this.posts.push(post)
    },
  },
  // On Page Load
  created: async function () {
    const vue = this
    const posts = await this.getPosts()
    for (post of posts) {
      const {title, url: link} = post.data
      // Figure out how many rows to span
      const span = Math.floor(title.length / this.spanBreak) + 1
      this.createPost({
        title, link, span
      })
    }
    console.log(this.posts)
  }
})
              
            
!
999px

Console