Add a z-index element.
In addition, the element must also be positioned in order to work with z-index . So add position:relative too.
9.9.1 Stack Level Detection: 'z-index' Property
z-index: used for: positioned elements
Each box has a position in three dimensions. In addition to their horizontal and vertical positions, the boxes lie along the z axis and are formatted one on top of the other. Z-axis positions are especially important when drawers are stacked visually. This section discusses how cells can be located along the z axis.
Updated Codepen - Now it works.
.tile:hover, .tile2:hover { z-index: 1; position: relative; }
To solve the second problem, the elements appear on a new line, because their width does not add up, since it is 1px turned off from abroad.
33.3% + 33.3% + 33.3% + 1px ! = 100%
You have several different options:
If you decide to use box-sizing , you need the appropriate providers / prexes if you want to get support across all browsers. I would use something like:
.tile2 { width: 33.3%; border-left: 1px solid #ddd; box-sizing: border-box; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; }
Updated Codepen using box-sizing .
source share