你好我工作的網站上使用的瓷磚這樣的: 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