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="dropContainer" class="drop-container">
<span>拖曳檔案至此上傳</span>
</div>
<div id="msg"></div>
              
            
!

CSS

              
                .drop-container {
  width: 600px;
  height: 400px;
  border: 4px dashed #000;
  line-height: 400px;
  text-align: center;
}
              
            
!

JS

              
                console.clear();
  var firebaseConfig = {
    apiKey: "AIzaSyB3RMejYHAnWxAAk_1R9YtF4EcET7FU8hg",
    authDomain: "fir-a6c96.firebaseapp.com",
    databaseURL: "https://fir-a6c96.firebaseio.com",
    projectId: "fir-a6c96",
    storageBucket: "fir-a6c96.appspot.com",
    messagingSenderId: "918985325909",
    appId: "1:918985325909:web:851298d4d1656730"
  };
const db = firebase.initializeApp(firebaseConfig);


const dropContainer = document.getElementById("dropContainer");
const msg = document.getElementById("msg");

// 將這個範例存進 Storage drag-and-drop/ 資料夾
const folder = "drag-and-drop/" 

dropContainer.addEventListener("drop", event => {
  event.preventDefault();
  msg.textContent = "";
  
  const file = event.dataTransfer.files[0];
  const name = file.name
  const fullPath = `${folder}${name}`;
  const storageReference = firebase.storage().ref(fullPath);
  const task = storageReference.put(file);

  task.on(
    "state_changed",
    function progress(snapshot) {},
    function error() {
      msg.textContent = "上傳失敗";
    },
    function complete() {
      msg.textContent = "上傳成功";
    }
  );
});

dropContainer.addEventListener("dragover", event => {
  event.preventDefault();
});

              
            
!
999px

Console