cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

Code Indentation


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.

    <ul><a href="/">首页</a></ul>
  <div class="Main-header">Header</div>
  <div class="Main-content">
    <div class="Content">Content</div>
    <div class="Sidebar">
      <div class="Sidebar-content">Sidebar</div>
  <div class="Main-footer">Footer</div>
              .Main-header {
  height: 300px;
  background-color: yellow;

.Main-content {
  width: 960px;
  min-height: 1000px;
  margin: 0 auto;
  background-color: orange;

  &:after {
    content: "\0020";
    display: table;

  &:after {
    clear: both;

.Sidebar {
  float: left;

.Content {
  width: 100%;
  background-color: green;

.Sidebar {
  position: relative;

.Sidebar-content {
  position: absolute;
  top: 50px;
  width: 120px;
  height: 250px;
  margin-left: -80px;
  background-color: pink;

  &.is-fixed {
    position: fixed;

              initFloatSidebar = ->
  sidebar = $(".Sidebar-content")

  if sidebar.size() > 0
    topToDoc = sidebar.offset().top
    parentTopToDoc = sidebar.parent().offset().top
    topToParent = topToDoc - parentTopToDoc  # 不通过 sidebar.css("top"); 获取值是避免没设置 top 的情况(即值为 auto)。

    $(window).on "scroll", ( evt ) ->
      scrollTop = document.body.scrollTop or document.documentElement.scrollTop

      if scrollTop < document.documentElement.scrollHeight - sidebar.height()
        if scrollTop > parentTopToDoc
          sidebar.addClass "is-fixed"
          sidebar.removeClass "is-fixed"

$(document).ready initFloatSidebar

Loading ..................