-2

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.

Brit24
  • 65
  • 8
  • 3
    We need to see the code you tried – j08691 Mar 22 '17 at 20:41
  • I guess all I need to know is if there is a CSS property that will make all the boxes the same height? I thought that would be height, but that does not change anything. – Brit24 Mar 22 '17 at 20:42

2 Answers2

1

You have to define how overflowing content is handled.

.cut-content {
    overflow: hidden;
}
Marijan
  • 1,825
  • 1
  • 13
  • 18
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