I am creating a battleship game, where there is a generated grid on the board, where each square is a colored box with a number, and is its own div. The problem I'm having is that when one of the divs gets some extra content in it, it makes that particular div longer than the rest of the divs, which throws off the whole grid. How do I make sure all of the divs are the same height no matter if they have extra content or not? I have tried adding a height property to the CSS, but it does not change the actual height of the colored box.
Asked
Active
Viewed 59 times
2 Answers
1
You have to define how overflowing content is handled.
.cut-content {
overflow: hidden;
}

Marijan
- 1,825
- 1
- 13
- 18
-
-
-
1I hope the OP didn't set the div to `display: inline` or `display: table`. That would explain why setting the height has no effect as stated. ;) – Marijan Mar 22 '17 at 20:51
-
0
The answer is height
. You might be fighting specificity. Try the following:
.grid_div {
height: 100px;
height: 100px!important; /* if the previous does not work */
max-height: 100px;
max-height: 100px!important; /* if the previous does not work */
overflow: hidden; /* just for the visual effect */
display: inline-block; /* choose inline-block or block */
display: block; /* choose inline-block or block */
}

Mr. Hugo
- 11,887
- 3
- 42
- 60
-
-
Then you go here: http://stackoverflow.com/questions/1554928/how-to-hide-table-row-overflow – Mr. Hugo Mar 22 '17 at 21:13
-
1Why not, the op should post enough code that shows the issue, not us to guess what went wrong ;) – G-Cyrillus Mar 22 '17 at 22:11
-