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>
<div class="absolute-2">
<strong>position: absolute (絕對定位)-以網頁為定位點</strong><br> 
此元素被設定為絕對定位,但其父元素的 position 沒有設定,因此被默認為 "static",不屬於 relative、absolute、fixed 或是 inherit 的任一個,因此該元素會以整個網頁區域為定位基準,從最上方往下移動 30 px、從最右方往左移動 30 px。<br>
</div>
<div id="relative-2">這個元素是「相對定位(position:relative)」的區塊。
<div class="absolute-2">
<strong>position: absolute (絕對定位)-以父元素為定位點</strong><br>
這裡又來一個被設定成絕對定位(position: absolute;)的元素,此例的父層元素 position 有設定 relative,因此會以父元素為定位基準,從最上方往下移動 30 px、從最右方往左移動 30 px。<br>
</div>
  </div>



              
            
!

CSS

              
                div {
  text-align: left;
  border: 5px solid magenta;
  font-weight: 600px;
  font-size: 16px;
  box-sizing: border-box;
  padding: 4px;
}
#relative-2 {  
  border: none;
  background-color: orange;
  position: relative;
  top: 50px;
  height: 100px;
  max-width: 50%;
  height:500px;
}
.absolute-2 {
  text-align: left;
  border-color: red;
  position: absolute;
  top: 30px;
  right: 30px;
  max-width: 50%;
  background-color: #f2f2f2;
  box-shadow: 6px 6px rgba(0, 0, 0, 0.3)
}

  
              
            
!

JS

              
                
              
            
!
999px

Console