自動化水平滾動瓷磚我想不JS
製造新聞水平滾動瓷磚滑蓋純CSS 創建不同的滾動純CSS
我試着用flexbox,這
.spotlight-wrapper {
width: 100%;
overflow-x: auto;
}
.spotlight-wrapper .spotlight {
list-style: none;
height: 230px;
display: flex;
flex-direction: column;
flex-wrap: wrap;
justify-content: bottom;
padding: 0;
}
.spotlight-wrapper .spotlight li {
width: 220px;
height: 220px;
background: #ccc;
margin: 5px;
}
.spotlight-wrapper .spotlight li.small {
width: 105px;
height: 105px;
}
.spotlight-wrapper .spotlight li.medium {
width: 220px;
height: 105px;
/*
\t \t \t \t * Idea to fix it, but will cause
\t \t \t \t * issue if the medium tile in the
\t \t \t \t * bottom level, and there are 2 small
\t \t \t \t * tiles next to it in the top level
\t \t \t \t */
/* & + .small + .small{
\t \t \t \t \t display: block;
\t \t \t \t \t clear: both;
\t \t \t \t \t justify-content: bottom;
\t \t \t \t \t margin-top: 120px;
\t \t \t \t \t margin-left: -110px;
\t \t \t \t } */
}
.spotlight-wrapper .spotlight li.red {
background: red;
}
<div class="spotlight-wrapper">
\t <ul class="spotlight">
\t \t <li>Tile #1</li>
\t \t <li class="small">Tile #2</li>
\t \t <li class="small">Tile #3</li>
\t \t <li class="medium">Tile #9</li>
\t \t <li class="medium">Tile #10</li>
\t \t <li>Tile #2</li>
\t \t <li class="medium red">Tile #1</li>
\t \t <li class="small red">Tile #2</li>
\t \t <li class="small red">Tile #3</li>
\t \t <li>Tile #5</li>
\t \t <li>Tile #7</li>
\t \t <li>Tile #8</li>
\t \t <li class="medium">Tile #9</li>
\t \t <li class="medium">Tile #10</li>
\t \t <li>Tile #11</li>
\t \t <li>Tile #12</li>
\t \t <li class="small">Tile #13</li>
\t \t <li>Tile #14</li>
\t \t <li>Tile #15</li>
\t \t <li>Tile #16</li>
\t \t <li>Tile #17</li>
\t \t <li>Tile #18</li>
\t \t <li>Tile #19</li>
\t \t <li>Tile #20</li>
\t </ul>
但是,如果您檢查紅色瓷磚,它不正確的方式對齊,我可以使用邊距修復它(檢查com但是如果寬瓦片在最下面的行中,並且在下一個塊中有2個小瓦片會引起其他問題,並且在下一個塊中有2個小瓦片,
另外,如果只有一個小瓦片,則將創建空的空間。
您可能希望從這裏開始您的故障排除:**'證明內容:bottom' **(有沒有這樣的值)。對於有效的值和其他對齊選項,可以幫助你在這裏看到:[方法對齊Flex項目](http://stackoverflow.com/a/33856609/3597276) –
非常好的一個,感謝分享,希望答案亮起來有 –
也許列CSS更準確? http://codepen.io/anon/pen/pgEGvG –