你好我工作的网站上使用的瓷砖这样的: CSS瓷砖定位
正如你看到的几乎一切准备就绪,但有一个瓷砖比别人低。我想把它放在正确的地方,但现在我还没有想到。我被工作封锁了,除非它能够完美地工作。
我的代码减:
.tile-loop(@index: 1) when (@index <= 6){
.tile-loop(@index + 1);
&[email protected]{index}x1{
width: (@index * @tile-width) + ((@index - 1) * 2 * @tile-margin);
height: @tile-height;
}
&[email protected]{index}x2{
width: (@index * @tile-width) + ((@index - 1) * 2 * @tile-margin);
height: 2 * @tile-height + 2 * @tile-margin;
}
&[email protected]{index}x3{
width: (@index * @tile-width) + ((@index - 1) * 2 * @tile-margin);
height: 3 * @tile-height + 4 * @tile-margin;
}
&[email protected]{index}x4{
width: (@index * @tile-width) + ((@index - 1) * 2 * @tile-margin);
height: 4 * @tile-height + 6 * @tile-margin;
}
&[email protected]{index}x5{
width: (@index * @tile-width) + ((@index - 1) * 2 * @tile-margin);
height: 5 * @tile-height + 8 * @tile-margin;
}
&[email protected]{index}x6{
width: (@index * @tile-width) + ((@index - 1) * 2 * @tile-margin);
height: 6 * @tile-height + 10 * @tile-margin;
}
}
.tiles {
padding: 40px 0;
margin: 0;
border-bottom: 1px solid @color-black;
.grid {
margin-left: -10px;
margin-right: -10px;
display: block;
.tile {
float: left;
margin: @tile-margin;
overflow: hidden;
position: relative;
.tile-loop();
}
.clear {
clear: both;
display: block;
width: 100%;
}
}
}
HTML:
<div class="tiles">
<div class="grid">
<div class="tile t3x4" style="background: red;"></div>
<div class="tile t3x2" style="background: blue;"></div>
<div class="tile t3x2" style="background: green;"></div>
<div class="clear"></div>
<div class="tile t2x3" style="background: red;"></div>
<div class="tile t2x1" style="background: blue;"></div>
<div class="tile t2x2" style="background: green;"></div>
<div class="tile t2x2" style="background: green;"></div>
<div class="tile t1x1" style="background: green;"></div>
<div class="tile t1x1" style="background: green;"></div>
</div>
</div>
请帮助。
为什么不使用网格布局CSS框架,已经解决了这个问题? – user3791372