Resposnive居中六边形honeycombe布局按特定顺序

时间:2015-09-22 09:38:50

标签: css responsive-design hexagonal-tiles

我正在尝试使用特定布局中的内容创建一些六边形块。我有四个块开始,顶部有一个块,然后是一行,然后是一行,如下图所示。我在互联网上找到的所有演示问题都是<li>使用float:left。我尝试使用display:inline-blockdisplay:inline,但都没有效果。我还需要它才能做出响应,这样块就会在iPad上和下面的行中分成一行。有没有人知道这个问题的解决方案,还是我需要打电话给A-Team?

http://tandsdev.co.uk/_testing/hexagan_layout.png

1 个答案:

答案 0 :(得分:1)

我在代码下面有实现,你可以尝试

body{
  font-family: 'Open Sans', arial, sans-serif;
  background:#fff;

}
*{
  margin:0;
  padding:0;
}
#categories{
  overflow:hidden;
  width:100%;   /* you can change the width here */
  margin:0 auto;
}
.clr:after{
  content:"";
  display:block;
  clear:both;
}
#categories li{
  position:relative;
  list-style-type:none;
  width:27.85714285714286%; /* = (100-2.5) / 3.5 */
  padding-bottom: 32.16760145166612%; /* =  width /0.866 */
  float:left;
  overflow:hidden;
  visibility:hidden;

  -webkit-transform: rotate(-60deg) skewY(30deg);
  -ms-transform: rotate(-60deg) skewY(30deg);
  transform: rotate(-60deg) skewY(30deg);
}
#categories li:nth-child(3n+2){
  margin:0 1%;
}
#categories li:nth-child(6n+4){
  margin-left:0.5%;
}
#categories li:nth-child(6n+4), #categories li:nth-child(6n+5), #categories li:nth-child(6n+6) {
    margin-top: -6.9285714285%;
  margin-bottom: -6.9285714285%;

  -webkit-transform: translateX(50%) rotate(-60deg) skewY(30deg);
  -ms-transform: translateX(50%) rotate(-60deg) skewY(30deg);
  transform: translateX(50%) rotate(-60deg) skewY(30deg);
}
#categories li:nth-child(6n+4):last-child, #categories li:nth-child(6n+5):last-child, #categories li:nth-child(6n+6):last-child{
  margin-bottom:0%;
}
#categories li *{
  position:absolute;
  visibility:visible;
}
#categories li > div{
  width:100%;
  height:100%;
  text-align:center;
  color:#fff;
  overflow:hidden;
  background: #000;
  -webkit-transform: skewY(-30deg) rotate(60deg);
  -ms-transform: skewY(-30deg) rotate(60deg);
  transform: skewY(-30deg) rotate(60deg);

    -webkit-backface-visibility:hidden;

}

/* HEX CONTENT */
#categories li img{
  left:-100%; right:-100%;
  width: auto; height:100%;
  margin:0 auto;
}

#categories div h1, #categories div p{
  width:90%;
  padding:0 5%;
}
#categories li h1{
/*  bottom:110%;  */
  font-style:italic;
  font-weight:normal;
  font-size:1.5em;
  padding-top:50%;
  padding-bottom:100%;
}
#categories li h1:after{
    content:'';
  display:block;
  position:absolute;
  bottom:-1px; left:45%;
  width:10%;
  text-align:center;
  z-index:1;
  border-bottom:2px solid #fff;
}
#categories li p{
    padding-top:50%;
    top:10%;
    padding-bottom:50%;
}


/* HOVER EFFECT  */

#categories li div:hover h1 {

}

#categories li div:hover p{

}

</style>




<ul id="categories" class="clr">
  <li class="pusher"></li>
    <li>

      <div>
        <h1>Lorem Ipsum is simply</h1>
        <p>There are many variations of passages of Lorem Ipsum available</p>
    </div>
  </li>
   <li class="pusher"></li>
    <li>
   <div>
        <h1>Lorem Ipsum is simply</h1>
        <p>There are many variations of passages of Lorem Ipsum available</p>
    </div>
  </li>
  <li>
   <div>
        <h1>Lorem Ipsum is simply</h1>
        <p>There are many variations of passages of Lorem Ipsum available</p>
    </div>
  </li>
   <li class="pusher"></li> <li class="pusher"></li>
     <li>
       <div>
        <h1>Lorem Ipsum is simply</h1>
        <p>There are many variations of passages of Lorem Ipsum available</p>
    </div>
  </li>



</ul>