Pen Settings

HTML

CSS

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

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

              
                <h3>Those are not perfectly centered</h3>
<p>because we are trying to center element with size of even amount of pixels inside an element with size of odd amount of pixels - or the other way</p>
<p>40px in 45px:</p>

<b>absolute centering</b>
<div class="a">
  <div class="b"></div> 
</div>

<b>flex centering</b>
<div class="c">
  <div class="d"></div> 
</div>
<p>Method doesn't matter</p>

<hr />
<h3>Those are perfectly centered</h3>
<p>Right now both elements even in size, result: <b>Perfectly centered</b></p>

<p>40px in 46px:</p>
<b>absolute centering</b>
<div class="e">
  <div class="f"></div> 
</div>

<b>flex centering</b>
<div class="g">
  <div class="h"></div> 
</div>
<br />
<p>Or odd in size: <b>Perfectly centered</b></p>

<p>39px in 45px:</p>
<div class="i">
  <div class="j"></div> 
</div>
              
            
!

CSS

              
                .a, .c, .e, .g, .i
  background-color: grey
  border-radius: 50%
  height: 45px
  width: 45px

.b, .d, .f, .h, .j
  background-color: lightgray
  border-radius: 50%
  height: 40px
  width: 40px

.a
  position: relative
  
.b
  position: absolute
  top: 50%
  left: 50%
  transform: translate(-50%, -50%)
  
.c
  align-items: center
  display: flex
  justify-content: center

.e
  position: relative
  height: 46px 
  width: 46px
  
.f
  position: absolute
  top: 50%
  left: 50%
  transform: translate(-50%, -50%)
 
.g
  align-items: center
  display: flex
  justify-content: center
  height: 46px 
  width: 46px
  
.i
  align-items: center
  display: flex
  justify-content: center
  height: 45px
  width: 45px
  
.j
  width: 39px
  height: 39px
  

              
            
!

JS

              
                
              
            
!
999px

Console