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

              
                .container#app
  h1 動態切換:class 與 :style
  hr
  h3 ●為.box 加上動態 class
  p :class="{ '要加入的className' : 判斷式}"
  p 如果要動態的調整className,調整判斷式即可
  .box( :class="{'rotate':isTransform,'bgc-blue':boxColor}")
  br
  button.btn(@click="isTransform = !isTransform") 旋轉物件
  input(type="checkbox" v-model="boxColor"  id="checkbox1") 
  label(for="checkbox1") 變色
  hr
  h3 ●使用物件寫法
  p 不能直接使用 - 這做微物劍選取的名稱,必須使用中括號[]的方式來選取
  .box( :class="classObject")  
  br
  button.btn(@click="classObject.rotate = !classObject.rotate") 旋轉物件
  input(type="checkbox" v-model="classObject['bgc-blue']" value="變色" id="checkbox2") 
  label(for="checkbox2") 變色
  hr
  h3 ●使用陣列寫法
  P 適用於className 長度不確定者
  .box(:class="arrayClass")
  .arrary
    input(type="checkbox" class="form-check-input" id="checkbox3" v-model="arrayClass" 
          value="bgc-blue" )
    label(class="form-check-label" for="checkbox3") 變色
    input(type="checkbox" v-model="arrayClass"  id="checkbox4" value="rotate") 
    label(for="checkbox4") 旋轉
  hr
  h3 ●綁定行內樣式
  P :style="{'樣式名稱' : '樣式的值'}"
  p 把 - 轉微駝峰式的寫法(ex: backgroundColor)
  .box(:style=" {backgroundColor : '#D6EAF8'}")
  .box(:style="styleObject")
  .box(:style="[styleObject,styleObject2]")
    
  
  
              
            
!

CSS

              
                .container
  font-family: 微軟正黑體
  padding: 25px
  h3
    margin-bottom: 20px
  .box
    width: 100px
    height: 100px    
    transition: 0.5s
    border-radius: 5px
    background-color: #FADBD8
    margin: 20px 10px 20px 0px
    display: inline-block    
  .bgc-blue
    background-color: #D6EAF8
  button
    width: 100px
    height: 40px
    border: none
    border-radius: 5px
    background-color: #ABEBC6
    color: #555
    margin-right: 10px
  .rotate
    transform: rotate(45deg)
  label
    margin-right: 10px
  

              
            
!

JS

              
                var vm = new Vue({
  el: '#app',
  data:{
    isTransform : false,
    boxColor: false,
    classObject :{
      'rotate' : false,
      'bgc-blue' : false,
    },
    //array 操作
    arrayClass:[],
    styleObject: {
      backgroundColor: '#D6EAF8',
      border: '1px solid #000'
    },
    styleObject2: {
      boxShadow: '3px 3px 5px rgba(0, 0, 0 , 0.8)'
    },
    styleObject3: {
      userSelect: 'none'
    } 
  }
})
              
            
!
999px

Console