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

              
                <div class="container">
  <h2>Flexbox Layout</h2>
  <div class="wrapper flex">
    <div class="column">One</div>
    <div class="column">Two</div>
    <div class="column">Three</div>
  </div>
</div>

<div class="container">
  <h2>Grid Layout</h2>
  <div class="wrapper grid">
    <div class="column">One</div>
    <div class="column">Two</div>
    <div class="column">Three</div>
  </div>
</div>




<form>
  <h2>请选择你想要的display值</h2>
  <div class="control">
    <label for="flex">Flexbox:</label>
    <select id="flex">
      <option value="flex">flex</option>
      <option value="inline-flex">inline-flex</option>
      <option value="block flex">block flex</option>
      <option value="inline flex">inline flex</option>
    </select>
  </div>  
  <div class="control">
    <label for="grid">Grid:</label>
    <select id="grid">
      <option value="grid">grid</option>
      <option value="inline-grid">inline-grid</option>
      <option value="block grid">block grid</option>
      <option value="inline grid">inline grid</option>
    </select>
  </div>  
  <p>请使用Firefox 70+ 或 Firefox Nightly 71+ 查看Demo效果</p>
</form>  
              
            
!

CSS

              
                @import 'https://fonts.googleapis.com/css?family=Share+Tech+Mono';

@import 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css';

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
    width: 100vw;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: wrap;
    background-image: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/1376484/jess-harding-lqT6NAmTaiY-unsplash.jpg'),radial-gradient(#28a3dd, #0d7751);
    background-size: cover;
    background-position: center;
    font-family: "Share Tech Mono", monospace;
    background-blend-mode: multiply,screen, overlay;
    color: #fff;
}

h2{
  font-size: 3rem;
  text-align: center;
  text-shadow: .05em .05em .01em rgba(0,0,0,.5);
}

.container {
    position: relative;
    background-size: cover;
    background-position: center;
    backdrop-filter: blur(20px);
    background-color: rgba(255, 255, 255, 0.5);
    border-radius: 5px;
    padding:2vw;
    box-sizing: border-box;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
    transition: .3s ease;
    margin: 1vw;
    color: #fff;
}

.column {
  background-color: rgba(114,132,168,.5);
  padding: 2vh;
  border-radius: .25em;
  border: .2em solid currentColor;
  font-size: 2em;
  margin: 2vh;
  text-shadow: .05em .05em .01em rgba(0,0,0,.5);
}

.wrapper {
  resize: horizontal;
  overflow: hidden;
  position: relative;
  
  &::after {
    pointer-events: none;
    content: "🔜";
    font-size: 14px;
    position: absolute;
    height: 24px;
    width: 24px;
    text-align: center;
    bottom: -10px;
    right: -2px;
    z-index: 2;
    background-color: transparent;
    color: #fff;
  }
}


:root {
  --flex: flex;
  --grid: grid;
}

.flex {
  display: var(--flex);
  
  > div {
    flex: 1;
  }
}

.grid {
  display: var(--grid);
  grid-template-columns: repeat(3, 1fr);
}

form {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  font-size: 14px;
  padding: 2vh;
  background: rgba(0,0,0,.8);
  
  h2 {
    font-size: 14px;
    margin-bottom: 3vh;
  }
  
  .control {
    display: grid;
    grid-template-columns: 80px 1fr;
    margin-bottom: 10px;
    place-items: center;
    text-align: right;
  }
  
  p {
    position: absolute;
    bottom: 10px;
    right: 10px;
    left: 10px;
    font-size: 12px;
    text-align: center;
  }
}
              
            
!

JS

              
                const gridSelector = document.querySelector('#grid')
const flexSelector = document.querySelector('#flex')

flexSelector.addEventListener('change', e => {
  document.documentElement.style.setProperty('--flex', e.target.value)
})

gridSelector.addEventListener('change', e => {
  document.documentElement.style.setProperty('--grid', e.target.value)
})
              
            
!
999px

Console