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

              
                #app
  .postarea
    .posts(:style="computedLeft")
      .postbox(v-for="(work, id) in works", :class="{curItem: id == nowIndex}")
        .cover(:style="coverUrl(work.cover)")
          .infos
            h1 {{work.title}}
            h5 {{work.description}}
  .control_left(@click="delta(-1)")
    i.fa.fa-angle-left
  .control_right(@click="delta(1)")
    i.fa.fa-angle-right
              
            
!

CSS

              
                @mixin flex_center
  display: flex
  justify-content: center
  align-items: center
  
@mixin size($w, $h: $w)
  width: $w
  height: $h
  
@mixin trans($t: 0.5s, $td: 0s)
  transition: $t $td
  
  
*
  // border: solid 1px white
  
html, body
  +size(100%)
  overflow: hidden
  background-color: #1c1c1c
  
#app
  +size(100%)
  +flex_center
  
.postarea
  +size(930px, 250px)
  white-space: nowrap
  overflow: hidden
  
.posts
  height: 100%
  position: relative
  transition: .5s
  
.postbox
  display: inline-block
  height: 100%
  
  .cover
    +size(330px, 100%)
    +flex_center
    +trans
    margin: 0 300px
    background-size: 100% auto
    background-position: center center
    background-repeat: no-repeat
    cursor: pointer
    
    &:hover
      +size(340px, 110%)
      
      .infos
        transform: translate(-220px)
    
  .infos
    color: white
    transform: translateX(-200px)
    text-shadow: 0 0 30px rgba(0,0,0,.3)
    +trans
    
    *
      margin: 0
    h1
      margin-bottom: 10px
      font-size: 50px
      font-weight: 400
      
    h5
      background-color: white
      color: black
      padding: 4px 12px
      font-size: 20px
      font-weight: 300
      box-shadow: 0 0 30px rgba(0,0,0,.3)
      
.curItem
  .cover
    animation: fadeIn 1s ease both
  
  .infos
    h5
      animation: slideIn 1s 0.2s ease both
    
@keyframes fadeIn
  0%
    opacity: 0
    transform: translateX(30px)
    filter: saturate(0%) //黑白濾鏡
  
  100%
    opacity: 1
    transform: translateX(0px)
    filter: saturate(100%)
  
@keyframes slideIn
  0%
    opacity: .5
    transform: translate(-50px)
  
  100%
    opacity: 1
    transform: translate(0px)
      
.control_left, .control_right
  +size(40px)
  border: solid 1px white
  position: fixed
  border-radius: 50%
  color: white
  font-size: 30px
  +flex_center
  cursor: pointer
  +trans
  
  &:hover
    background-color: white
    color: black
  
.control_left
  left: 50px

.control_right
  right: 50px
              
            
!

JS

              
                var works = [
  {
    title: "海象樂園",
    description: "趴在冰層上的懶惰動物",
    cover: "https://unsplash.it/400/300?image=1084"
  },
  {
    title: "搭船遊去",
    description: "不會游泳只好搭船",
    cover: "https://unsplash.it/400/300?image=1083"
  },
  {
    title: "老年學鋼琴",
    description: "學習永遠不嫌晚!",
    cover: "https://unsplash.it/400/300?image=1082"
  },
  {
    title: "高樓的一隅",
    description: "繁複的幾何線條構築",
    cover: "https://unsplash.it/400/300?image=1081"
  },
  {
    title: "草莓來襲",
    description: "聽見果農的艱辛",
    cover: "https://unsplash.it/400/300?image=1080"
  },
  {
    title: "探索宇宙",
    description: "看見光的速度與殘影",
    cover: "https://unsplash.it/400/300?image=1079"
  }
];

var vm = new Vue({
  el: '#app',
  data: {
    works: works,
    nowIndex: 0,
    span: 930
  },
  computed :{
    computedLeft (){
      var result = {
        'left': (-this.nowIndex * this.span) + 'px'
      }
      console.log(result)
      return result
    }
  },
  methods: {
    delta (d){
      // 取總長的餘數控制id範圍
      this.nowIndex = (this.nowIndex + d + this.works.length) % this.works.length
    },
    coverUrl (url) {
      return {
        'background-image': 'url(' + url + ')'
      }
    }
  }
})
              
            
!
999px

Console