http://codepen.io/airen/details/XbVBZo

<div><span>1</span></div>
<div><span>2</span></div>
<div><span>3</span></div>
<div><span>4</span></div>
<div><span>5</span></div>
<div><span>6</span></div>
<div><span>7</span></div>
<div><span>8</span></div>
<div><span>9</span></div>
<div><span>10</span></div>


SCSS代码:

body {
  width: 100%;
  font-size: 0;
  text-align: center;
}
div{
  display: inline-block;
  width: 20%;
  background: green;
  font-size: 12px;
  position: relative;
  vertical-align: middle;
  
  
  &:nth-child(2n){
    background: orange;
  }
  
  &:before {
    content:"";
    display: inline-block;
    padding-bottom: 100%;
    width: .1px;
    vertical-align: middle;
  }
  span {
    display: inline-block;
    vertical-align: middle;
    font-size: 4em;
    color: #fff;
  }
}

CSS代码:

body {
  width: 100%;
  font-size: 0;
  text-align: center;
}

div {
  display: inline-block;
  width: 20%;
  background: green;
  font-size: 12px;
  position: relative;
  vertical-align: middle;
}
div:nth-child(2n) {
  background: orange;
}
div:before {
  content: "";
  display: inline-block;
  padding-bottom: 100%;
  width: .1px;
  vertical-align: middle;
}
div span {
  display: inline-block;
  vertical-align: middle;
  font-size: 4em;
  color: #fff;
}

 

posted on 2016-06-22 11:24  JeremyLee87  阅读(4245)  评论(0编辑  收藏  举报