Pen Settings



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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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.


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.


                <h1>CSS Position Types Demo</h1>

<div id="parent-container">
  I am the ancestor of all the boxes inside me. Also, I am positioned <span>relatively.</span> What is affected if I were <span>static</span>?
  <div id="static"><span>static</span> positioning means that this element is <i>unpositioned</i>. It is rendered where the element is by default according to the HTML. It's not participating in all the positioning fun.

    <div class="absolute">
      this <span>absolutely-positioned</span> element has <i>escaped</i> its <span>static</span> parent element.</br>It is now positioned relative to its nearest <span>relative</span> ancestor.


  <div id="relative"><span>relative</span> positioning means the element is positioned relative to itself. Without using the <span>top</span>, <span>right</span>, <span>bottom</span>, or <span>left</span> properties, it behaves like a <span>static</span> element. Try adding
    properties to move this element!

    <div class="absolute"><span>absolute</span> means positioned relative to its nearest <i>positioned</i> parent positioned element. Uncomment the following HTML!
<!--      The absolutely-positioned element is taken out of the regular DOM flow.-->
     <!-- <br>
       When an element is positioned absolutely, it is taken out of the normal flow and the other elements fill in its gap.  This allows it to have a <span>z-index</span> property, and means that it can <i>overlay</i> over other elements. <br> Basically, absolute elements are on a different layer. I've illustrated this by giving the absolute elements a box-shadow - like they're 'above' the other elements! Try deleting the <span>background-color</span> property of this element!-->


  <div id="fixed">
    <span>fixed</span> positioning means that I am positioned relative to the browser window a.k.a the viewport. Even if you scroll, I'll be right here. PS - extra info in the HTML!
<!--    Using a CSS3 transform property on me results in my position becoming relative to a parent ancestor instead. Check the comments for this pen for more info. Thanks to @ericnkatz for the heads-up!-->



                h1 {
  text-align: center;
  text-transform: uppercase;
  font-family: 'Bree Serif', serif;
  background: linear-gradient(135deg, red, blue);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;

div {
  border: 5px solid teal;
  font-family: 'Courier New', monotype;
  font-weight: 600;
  font-size: 14px;
  padding: 10px;
  margin: 2px;
  box-sizing: border-box;
/*visually separating properties by adding a grey bg*/

span {
  background-color: #b2b2b2;

#static {
  height: 100px;
  /*adding top, bottom, left, or right properties won't affect
  this element. Try it! Uncomment the code below to watch     absolutely nothing happen.*/
  /*  right: 500px;*/

#relative {
  border-color: orange;
  height: 150px;
  position: relative;
  /*Uncomment below or add top, bottom, left, or right properties to see this move*/

.absolute {
  border-color: red;
  position: absolute;
  bottom: 0;
  right: 0;
  max-width: 75%;
  /*delete or comment out the background-color property below to see what happens! Warning - it's gonna be messy.*/ 
  background-color: #f2f2f2;

  box-shadow: 6px 6px rgba(0, 0, 0, 0.3)

#parent-container {
  border-color: purple;
  height: 400px;
  /*this is positioned relatively. What happens to the red box if it wasn't?*/
  position: relative;

#fixed {
  border-color: blue;
  position: fixed;
    bottom: 0;
    left: 0;
  margin: 0;
  width: 300px


                /*Welcome to my Interactive CSS Positions Demo!

Read the page and walk through the HTML to see what's happening and read the content in the boxes. There are comments for you to read and properties to mess with.

Feel free to fork but credit where credit is due.

Copyright Banun Idris 2015