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

              
                <body>
  <div class="wrap">
    <div class="menu">
      <ul>
        <li><a href="#">回到首頁</a></li>
        <li><a href="#">關於我們</a></li>
        <li><a href="#">熱銷產品</a></li>
        <li><a href="#">購物車</a></li>
      </ul>
    </div>
    <div class="content">
      Lorem ipsum dolor sit amet consectetur, adipisicing elit. Similique excepturi nisi doloribus sapiente culpa
      dolorem dolores sint, expedita perferendis iure suscipit ut, laudantium animi praesentium dolorum. Esse
      debitis ipsa quam, soluta ex fuga quae iusto doloremque, incidunt, totam minima enim ad aliquam! Fugit
      dolorem maxime, saepe molestias veniam consequatur ut?
      Lorem ipsum dolor sit amet consectetur, adipisicing elit. Similique excepturi nisi doloribus sapiente culpa
      dolorem dolores sint, expedita perferendis iure suscipit ut, laudantium animi praesentium dolorum. Esse
      debitis ipsa quam, soluta ex fuga quae iusto doloremque, incidunt, totam minima enim ad aliquam! Fugit
      dolorem maxime, saepe molestias veniam consequatur ut?
      Lorem ipsum dolor sit amet consectetur, adipisicing elit. Similique excepturi nisi doloribus sapiente culpa
      dolorem dolores sint, expedita perferendis iure suscipit ut, laudantium animi praesentium dolorum. Esse
      debitis ipsa quam, soluta ex fuga quae iusto doloremque, incidunt, totam minima enim ad aliquam! Fugit
    </div>
  </div>
</body>

<div class="container description" style="margin-top: 20px;margin-bottom: 20px;">
  <h2>flex-shrink 計算方式</h2>
  <p>壓縮權重(sum): shrink * menu_width + shrink * content_width</p>
  <p>以此範例:</p>
  <p>sum = 3 * 300 + 1 * 900 = 1800</p>
  <hr>
  <p>元素壓縮率 (S): shrink * menu_width/壓縮權重(sum)</p>
  <p>以此範例:</p>
  <p>S1 = 3 * 300 / 1800 = 0.5</p>
  <hr>
  <p>元素寬度 (W): menu_width - S*剩餘寬度</p>
  <p>以此範例:</p>
  <p>W = 300 - 0.5*200 = 200</p>
  <p><small>註:剩餘空間是 (300+900) - 1000 算出來的</small></p>
</div>

              
            
!

CSS

              
                .wrap{
  max-width: 1000px;
  margin: 0 auto;
  display: flex;
}
.container {
  max-width: 1000px;
  margin: 0 auto;
}
.menu{
  flex-basis: 300px;
  color: blue;
  background: #000;
  padding-top: 10px;
  flex-shrink: 3;
}



.menu li a {
  display: block;
  text-align: center;
  padding-bottom: 10px;
  color: #fff;
}


.content{
  flex-basis: 900px;
  background: orange;
  color: #fff;
  flex-shrink: 1;
  padding: 10px 0px;
}

.description h2 {
  font-size: 24px;
  line-height: 1.5;
}
.description p {
  line-height: 1.5;
}
              
            
!

JS

              
                
              
            
!
999px

Console