css多列等寬分佈程式碼例項

antzone發表於2017-04-11

分享一段程式碼例項,它演示了多列等寬分佈效果。

程式碼例項如下:

[HTML] 純文字檢視 複製程式碼
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="http://www.softwhy.com/" />
<title>螞蟻部落</title>
<style>
.container {
  width: 400px;
  margin: 50px auto 0;
}
.justify {
  position: relative;
  width: 100%;
  height: 24px;
  text-align: justify;
  margin-bottom: 20px;
}
.justify i {
  width: 24px;
  line-height: 24px;
  display: inline-block;
  text-align: center;
  background: #333;
  color: white;
  border-radius: 50%;
  overflow: hidden;
  font-style: normal;
}
.justify:after {
  content: "";
}
.justify:after,
.justify b {
  display: inline-block;
  position: relative;
  top: -28px;
  *top: -9px;
  height: 1px;
  line-height: 0;
  width: 100%;
  background: #333;
  z-index: -1;
  *zoom: 1;
}
</style>
</head>
<body>
  <div class="container">
    <div class="justify">
      <i>1</i>
      <i>2</i>
      <i>3</i>
      <i>4</i>
      <i>5</i>
    </div>
    <div class="justify">
      <i>1</i>
      <i>2</i>
      <i>3</i>
      <i>4</i>
    </div>
    <div class="justify">
      <i>1</i>
      <i>2</i>
      <i>3</i>
    </div>
    <div class="justify">
      <i>1</i>
      <i>2</i>
    </div>
    <div class="justify">
      <i>1</i>
    </div>
  </div>
</body>
</html>

相關文章