I followed the excellent post on creating a grid of responsive squares to create, well, a grid of responsive squares.
What I need to do is create two background divs the span half the height and the full width so that I can attach events to them. These divs however, cannot interfere with the content in the cell.
This is what the square looks like in html
:
<div class="row-content">
<div class="content">
<div class="table">
<div class="table-cell numbers">
<span>100.08</span>
</div>
</div>
</div>
</div>
and the css
.row-content {
float:left;
position: relative;
width: 8%; /* 1 divide number of columns */
padding-bottom : 8%; /* = width for a 1:1 aspect ratio */
margin:0.16667%; /* = (100% - (% width * columns)) / (columns * 2) */
background-color:#1E1E1E;
overflow:hidden;
}
.content {
position:absolute;
height:98%; /* = 100% - 2*10% padding */
width:98%; /* = 100% - 2*5% padding */
padding: 1%;
}
.table{
display:table;
width:100%;
height:100%;
}
.table-cell{
display:table-cell;
vertical-align:middle;
}
.numbers{
font-weight:900;
font-size:12px;
color:#fff;
}
This results in the following:
Here's the fiddle.
I'd like two "hidden" divs behind the content. By hidden I mean divs with no content, there solely for the purpose of attaching events. Something like this:
I'm using Bootstrap 3 and jQuery.