大家,元素CSS網不換
漂亮的新進入網絡的發展,我想學習如何使用CSS美麗網格工具,但實際上,我堅持這一點:
我希望我的卡到下一行(與同列模板)中自動流一個接一個,但我實際上只看到在我的瀏覽器一卡。
我想這個問題是我在vh
.wrapper
高度。我試過px
和%
,但我真的堅持找到解決方案。
,如果有人有關於我對這個問題的想法,或任何評論我真的會喜歡(壞...還是不錯的?)編碼的方法!
/* Just some horrible stylization to better see boxes */
body {
padding: 0px;
margin: 0px;
}
div {
background-color: #f1c40f;
border: 1px solid white;
}
/* Definition of the 3 grids used*/
.wrapper {
height: 100vh;
box-sizing: border-box;
display: grid;
align-content: stretch;
justify-content: stretch;
grid-template-columns: 2fr 1fr 3fr 1fr 3fr 1fr 2fr;
grid-template-rows: 1fr 5fr 1fr;
grid-template-areas: "header header header header header header header"
"main main main main main main main"
"footer footer footer footer footer footer footer"
}
.main {
grid-area: main;
display: grid;
grid-template-columns: 60px 7fr 1fr;
grid-template-rows: 1fr;
grid-template-areas: "sidebar box-content box-content";
}
/* This box-content's grid-template-columns have many ones, it is done to modify
only the grid-template-areas with media-queries for larger screen*/
.box-content {
grid-area: box-content;
display: grid;
grid-template-columns: 1fr 2fr 1fr 2fr 1fr 2fr 1fr 2fr 1fr;
grid-template-rows: 1fr 7fr 1fr;
grid-auto-flow: row;
grid-template-areas: ". . . . . . . . ."
". card card card card card card card."
". . . . . . . . .";
}
/* Definition of the different element's grid-area*/
.header {
grid-area: header;
}
.sidebar {
grid-area: sidebar;
}
.card {
grid-area: card;
}
.footer {
grid-area: footer;
}
<!-- I apologize for non-semantic tags, only a quick prototyping -->
<div class="wrapper">
<div class="header"> Header Header Header Header Header</div>
<div class="main">
<div class="sidebar">Sidebar Sidebar </div>
<div class="box-content">
<div class="card"> Card Card Card Card Card Card </div>
<div class="card"> Card Card Card Card Card Card </div>
<div class="card"> Card Card Card Card Card Card </div>
<div class="card"> Card Card Card Card Card Card </div>
</div>
</div>
<div class="footer"> Footer Footer Footer Footer Footer </div>
</div>
謝謝
嘿,感謝您的回答和鏈接,我會definetly切特出來,但爲第i個油墨我必須澄清我想要做的(我的英語不是最好的),並且圖像是我認爲最好的辦法:[圖片](https://ibb.co/hDoXrv)。我想卡全部放在中間列,逐行(並添加溢出:滾動.box-內容 – Halkeand