Skip to content

Instantly share code, notes, and snippets.

@jokemmy
Created September 12, 2017 07:34
Show Gist options
  • Select an option

  • Save jokemmy/b32fc5ccdd2bb581275caf01b992181e to your computer and use it in GitHub Desktop.

Select an option

Save jokemmy/b32fc5ccdd2bb581275caf01b992181e to your computer and use it in GitHub Desktop.
消除浮动

在响应式的左右布局中挺有用,也可以用在表单中代替常用的 grid 布局

// less
.clearfix {
  &:before,
  &:after {
    content: "";
    display: table;
  }
}

.clearfix:after {
  clear: both;
}

.clearfix {
  zoom: 1;
}

.float-left {
  float: left
}

.width-200 {
  width: 200px;
}

.height-300 {
  height: 300px;
}

.overflow-hidden {
  overflow: hidden;
}
<div className="clearfix">
  <div className="float-left width-200 height-300">占据左边200px</div>
  <div className="overflow-hidden height-300">占满右边区域</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment