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

Auto Save

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

              
                <!-- Centrer horizontalement avec text-align -->
<h2>Centrer horizontalement avec text-align</h2>
<div id="text-align">
  <img src="https://i.ibb.co/hVDCVmV/cadeau-noel.jpg">
</div>

<!-- Centrer horizontalement avec margin: auto -->
<h2>Centrer horizontalement avec margin: auto</h2>
<img id="margin-auto" src="https://i.ibb.co/hVDCVmV/cadeau-noel.jpg">

<!-- Centrer horizontalement avec display:flex-->
<h2>Centrer horizontalement avec display flex</h2>
<span id="display-flex-h">
  <img id="img-flex-h" src="https://i.ibb.co/hVDCVmV/cadeau-noel.jpg">
</span>

<!-- Centrer verticalement avec display:flex-->
<h2>Centrer verticalement avec display flex</h2>
<div id="display-flex-v">
  <img id="img-flex-v" src="https://i.ibb.co/hVDCVmV/cadeau-noel.jpg">
</div>

<!-- Centrer verticalement avec position et transform -->
<h2>Centrer verticalement avec position et transform</h2>
<div id="position-transform">
  <img id="img-absolute" src="https://i.ibb.co/hVDCVmV/cadeau-noel.jpg">
</div>

<!-- Centrer verticalement et horizontalement avec position et transform -->
<h2>Centrer verticalement et horizontalement avec position et transform</h2>
<div id="position-transform-bis">
  <img id="img-absolute-bis" src="https://i.ibb.co/hVDCVmV/cadeau-noel.jpg">
</div>
              
            
!

CSS

              
                h2 {
    text-align: center;
}

div, span {
  border: solid 1px black;
}

img {
  width: 200px;
}

#text-align {
    text-align: center;
 }

#margin-auto {
  width: 200px;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

#display-flex-h {
  display: flex;
  justify-content: center;
}

#img-flex-h {
  width: 200px;
}

#display-flex-v {
  display: flex;
  align-items: center;
  height: 300px;
}

#img-flex-v {
  width: 200px;
}

#position-transform {
  position: relative;
  height: 300px;
}

#img-absolute {
  width: 200px;
  position: absolute;
  top: 50%;
  transform: translate(0%, -50%);
}

#position-transform-bis {
  position: relative;
  height: 300px;
}

#img-absolute-bis {
  width: 200px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
              
            
!

JS

              
                
              
            
!
999px

Console