Pen Settings

HTML

CSS

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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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

              
                - var count = 7;
h1 字体与文字垂直居中
.container
  - var list = [{des: 'IFC (vectical-align: middle)', className: 'vertical-align-middle'}, {des: 'flex 布局', className: 'display-flex'}, {des: 'transform', className: 'transform'},]
  - var testWord = 'IXJxlg';
  .title 居中方式
  each item in list
    .line-container
      .line-description= item.des
      .line(class=item.className)
        - for(var x = 0; x < count; x++)
          span= testWord
.container
  .title 文字 content-area 大小 (font-size: 40px)
  .font-size
    .line
      - for(var x = 0; x < count; x++)
        span Ilpx
              
            
!

CSS

              
                @line-height: 50px;

h1 {
  text-align: center;
}

.title {
  font-size: 22px;
  font-weight: bold;
  margin-bottom: 10px;
}

.container {
  & + .container {
    margin-top: 40px;
  }
  width: 800px;
  margin: auto;
}
.line-container {
  & + .line-container {
    margin-top: 20px;
  }
  .line-description {
    font-size: 20px;
  }
}
.line {
  text-align: center;
  margin: 10px 0;
  padding: 20px 0;
  border-top: 1px solid black;
  border-bottom: 1px solid black;
  position: relative;
  &::after {
    display: block;
    content: "";
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    left: 0;
    width: 100%;
    height: 1px;
    background-color: rgba(0, 0, 0, 0.5);
  }
  span {
    line-height: 1em;
    font-size: 28px;
    + span {
      margin-left: 10px;
    }
  }
  span:nth-child(0) {
    font-family: "Epilogue";
  }
  span:nth-child(1) {
    font-family: "Roboto Mono";
  }
  span:nth-child(2) {
    font-family: "Sawarabi Mincho";
  }
  span:nth-child(3) {
    font-family: "Galada";
  }
  span:nth-child(4) {
    font-family: "Noto Serif";
  }
  span:nth-child(5) {
    font-family: "Righteous";
  }
}

.vertical-align-middle {
  font-size: 0;
  height: @line-height;
  line-height: @line-height;
  span {
    vertical-align: middle;
  }
}

.line-height {
  line-height: @line-height;
}

.display-flex {
  display: flex;
  height: @line-height;
  justify-content: center;
  align-items: center;
}

.transform {
  position: relative;
  height: @line-height;
  width: 100%;
  span {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    .span-left(@n, @i: 1) when (@i =< @n) {
      &:nth-child(@{i}) {
        left: ((@i - 1) * 100% / @n);
      }
      .span-left(@n, (@i + 1));
    }
    .span-left(7);
  }
}

.font-size {
  .line {
    display: flex;
    align-items: center;
    justify-content: center;
    &::after {
      display: none;
    }
    span {
      line-height: normal;
      font-size: 40px;
      outline: 1px solid red;
    }
  }
}

              
            
!

JS

              
                
              
            
!
999px

Console