我正在嘗試爲網絡製作棋盤遊戲。 我想使用Bootstrap使元素響應。如何使矩形居中並與Bootstrap響應?
遊戲的主要元素是一個矩形(遊戲板)。這應該以所有顯示大小爲中心,並且對所有邊都有一點餘量。
我必須應用哪些屬性和CSS規則? 我應該使用普通容器還是容器液?
在容器/行中創建一列並給它一類「col-xs-12」足夠嗎?
據我所知,這將適用於從最小到最大的所有設備向上。
我迄今爲止嘗試:
html, body {
height: 100%;
}
.container {
margin: 10px auto;
height: 100%;
display: flex;
justify-content: center;
background-color: #ababab;
}
.row {
width: 100%;
display: flex;
justify-content: center;
align-items: center;
}
.board {
margin: 10px;
height: 400px;
width: calc(100% - 40px);
background-color: teal;
border: 1px solid black;
font-size: 2.5em;
font-weight: bold;
color: white;
text-align: center;
line-height: 400px;
}
<div class="container">
<div class="row">
<div class="col-xs-12 board">The game-board</div>
</div>
</div>