Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


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


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.


Auto Save

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.


  each val in [701, 702, 703, 704, 705]
      img(src= ''+val)



    position: relative
    max-width: 600px
        position: absolute
        top: 0
        left: 0
        display: block
        width: 100%
        opacity: 0
        visibility: hidden
        transition: .8s
            position: static
            opacity: 1
            visibility: visible
    .prev, .next
        display: block
        position: absolute
        top: 50%
        transform: translateY(-50%)
        cursor: pointer
        transition: .4s
        background-color: rgba(0,0,0,.12)
        padding: 14px 12px
            background-color: rgba(0,0,0,.24)
            display: block
            content: ""
            width: 10px
            height: 10px
            border-top: 2px solid #fff
            border-right: 2px solid #fff
        left: 0
            transform: rotate(-135deg)
            margin-left: 4px
        right: 0
            transform: rotate(45deg)
            margin-right: 4px


                var counter = 0, // 一開始要顯示的圖,0 的話就是顯示第一張
    slide = document.querySelector('#slide'),
    items = slide.querySelectorAll('img'), // 抓取所有 img
    itemsCount = items.length, // 圖片總數 
    prevBtn = document.createElement('a'), // 上一張按鈕
    nextBtn = document.createElement('a'), // 下一張按鈕
    timer = 4000, // 4 秒換圖
    interval = window.setInterval(showNext, timer);  // 設定循環

prevBtn.classList.add('prev'); // 幫上一張按鈕加 class="prev" 給 CSS 指定樣式用
nextBtn.classList.add('next'); // 幫下一張按鈕加 class="next" 給 CSS 指定樣式用
slide.appendChild(prevBtn); // 將按鈕加到 #slide 裡

// 帶入目前要顯示第幾張圖 
var showCurrent = function(){
  	var itemToShow = Math.abs(counter % itemsCount); // 取餘數才能無限循環
  	[] items, function(el){
    	el.classList.remove('show'); // 將所有 img 的 class="show" 移除
  	items[itemToShow].classList.add('show'); // 將要顯示的 img 加入 class="show"

function showNext(){
	counter++; // 將 counter+1 指定下一張圖

function showPrev(){
	counter--; // 將 counter-1 指定上一張圖

// 滑鼠移到 #slider 上方時,停止循環計時
slide.addEventListener('mouseover', function(){
	interval = clearInterval(interval);

// 滑鼠離開 #slider 時,重新開始循環計時
slide.addEventListener('mouseout', function(){
	interval = window.setInterval(showNext, timer);

// 綁定點擊上一張,下一張按鈕的事件
nextBtn.addEventListener('click', showNext, false);
prevBtn.addEventListener('click', showPrev, false);

// 一開始秀出第一張圖,也可以在 HTML 的第一個 img 裡加上 class="show"