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

              
                <!DOCTYPE html>
<html>
<head>
</head>
<body>

<h1>The position property</h1>

<h2>position: static;</h2>
<p>The Parent1 element has position: static, and will remain in the natural flow of the page.
It will NOT act as anchor point for the absolutely positioned Child1 element:</p>
<div id="parent1">Parent1: position: static.
  <div id="child1">Child1: position: absolute, right: 15px, top: 70px</div>
</div>

<h2>position: relative;</h2>
<p>The Parent2 element has position: relative, and will remain in the natural flow of the page.
It will also act as anchor point for the absolutely positioned Child2 element:</p>
<div id="parent2">Parent2: position: relative.
  <div id="child2">Child2: position: absolute, right: 15px, top: 70px</div>
</div>

<h2>position: fixed;</h2>
<p>The Parent4 element has position: fixed, and will NOT remain in the natural flow of the page.
It will position itself according to the viewport.
It will also act as anchor point for the absolutely positioned Child4 element:</p>
<div id="parent4">Parent4: position: fixed, top:130px, right: 0.
  <div id="child4">Child4: position: initial, right: 15px, top: 70px</div>
</div>

<h2>position: absolute;</h2>
<p>The Parent3 element has position: absolute, and will NOT remain in the natural flow of the page.
It will position itself according to the closest positioned ancestor.
It will also act as anchor point for the absolutely positioned Child3 element:</p>
<div id="parent3">Parent3: position: absolute, top: 750px, right: 15px.
  <div id="child3">Child3: position: absolute, right: 15px, top: 70px</div>
</div>
</body>
</html>

              
            
!

CSS

              
                #parent1 {
  position: static;
  border: 1px solid blue;
  width: 300px;
  height: 100px;
}

#child1 {
  position: absolute;
  border: 1px solid red;
  top: 70px;
  right: 15px;
}

#parent2 {
  position: relative;
  border: 1px solid blue;
  width: 300px;
  height: 100px;
}

#child2 {
  position: absolute;
  border: 1px solid red;
  top: 70px;
  right: 15px;
}

#parent3 {
  position: sticky;
  border: 1px solid blue;
  width: 300px;
  height: 100px;
  top: 750px;
  right: 15px;
}

#child3 {
  position: inherit;
  border: 1px solid red;
  background-color: pink; 
  top: 70px;
  justify-content:right;
  right: 15px;
}

#parent4 {
  position: fixed;
  border: 1px solid blue;
  background-color: yellow;  
  width: 300px;
  height: 100px;
  right:0;
  top:130px;
}

#child4 {
  position: initial;
  border: 1px solid green;
  bottom:0px;
  right: 15px;
}
              
            
!

JS

              
                
              
            
!
999px

Console