I am building a Tic-Tac-Toe interface, currently using HTML, CSS, and Bootstrap. I'm trying to get the board to be perfectly squared (1:1) but I'm getting nowhere.
The boxes have to be taller so they use up more space. I can playing with the height
property using vw
/vh
units on the columns, but they won't keep the 1:1 ratio across all resolutions.
This other version has some "pads" on each side of the board and does the job but breaks on sizes smaller than tablets. Apart from that I lose too much space.
Now, here's the code for the Tic Tac Toe without pads:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Tic Tac Toe</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
<link rel="stylesheet" href="css/styles.css">
<script src="js/script.js"></script>
</head>
<body>
<div class="container-fluid">
<div class="row">
<div class="col-12 col-sm-2 ads"> "ads </div>
<div class="col-12 col-sm-6 content">
<div class="container-fluid tic-container">
<div class="row tic-row">
<div class="col-4 tic-box"> 1 </div>
<div class="col-4 tic-box"> 2 </div>
<div class="col-4 tic-box"> 3 </div>
</div>
<div class="row tic-row">
<div class="col-4 tic-box"> 4 </div>
<div class="col-4 tic-box"> 5 </div>
<div class="col-4 tic-box"> 6 </div>
</div>
<div class="row tic-row">
<div class="col-4 tic-box"> 7 </div>
<div class="col-4 tic-box"> 8 </div>
<div class="col-4 tic-box"> 9 </div>
</div>
</div>
</div>
<div class="col-12 col-sm-2 tic-panel"> PANEL-THINGY<br>Score:<br>Foo bar: stuff<br> Reset game and all that blah </div>
<div class="col-12 col-sm-2 ads"> ads </div>
</div>
</div>
</body>
</html>
.ads{
text-align: center;
margin: .4vw 0;
background: #F4CC70;
padding: .4vw;
}
.content{
margin: .4vw 0;
background: lightblue;
padding: .4vw;
}
.tic-panel{
border: solid 2px black;
margin: .4vw 0;
background: #66A5AD;
padding: .4vw;
}
.tic-box{
border: solid black 1px;
font-size: 5vw;
background: #6AB187;
text-align: center;
color: lavender;
}
.tic-box:hover{
background: #20948B;
}
Anyways, I would appreciate some pointers to what I'm doing wrong or what I should do. I guess I'm doing something wrong, not taking full advantage of bootstrap.
Also, I would love if you could tell me if I doing something against the principles of bootstrap, such as using rows
or col
where I shouldn't.