I want to basically have a table in my design where the size varies from 3 X 3 to 7 X 7 and need the full table to fit the small screens too.
So now going deeper, when the screen size is that of a mobile device I want the table to stretch full width, while on larger screens I need them to be in the center of the screen. Along with that in any screen size, the cells dimensions should be width = height, in other words a square.
How can I do this with CSS and TWITTER-BOOTSTRAP only?
P.S: I am new to bootstrap.
HTML
<div class="site-wrapper">
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand"><span class="icon ion-arrow-left-c"></span> Back</a>
</div>
</div>
</nav>
<div class="container">
<table class="table table-bordered">
<tr>
<td data-cell="0"></td>
<td data-cell="1"></td>
<td data-cell="2"></td>
</tr>
<tr>
<td data-cell="3"></td>
<td data-cell="4"></td>
<td data-cell="5"></td>
</tr>
<tr>
<td data-cell="6"></td>
<td data-cell="7"></td>
<td data-cell="8"></td>
</tr>
</table>
</div>
</div>
CSS
body {
background-color: #fff;
color: #ffffff;
text-align: center;
margin: 0;
}
html, body {
height: 100%;
background-color: #333;
/*overflow: hidden;*/
}
a {
color: #ffffff;
}
a:hover, a:active {
color: #ffffff;
}
.site-wrapper {
width: 100%;
height: 100%;
min-height: 100%;
-webkit-box-shadow: inset 0 0 100px rgba(0,0,0,.5);
box-shadow: inset 0 0 100px rgba(0,0,0,.5);
border-top: 5px solid #5A332B;
background-color: #ccbb99 !important;
}
2
Answers
Update: Just couldn’t do the pure css version and powered with jQuery:
If I understand your issue then you should change
table
structure todiv
. Because you need square box for every device screen size. Also you need to write little bit ofJavaScript
orjQuery
.Hope it will help.