HTML不能更改Div的高度 [英] HTML Can't Change Height of Div

查看:197
本文介绍了HTML不能更改Div的高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我正在玩井字游戏,但由于某些原因,我的div不会改变其高度.

So I'm working on a tic tac toe game but for some reason my divs won't change their height.

html {
  background-color:black;
  color:white;
  text-align:center;
}

.cell {
  border: 1px solid white;
  margin:1px;
  width:30%;height:30%;
}

<header>Tic Tac Toe</header>
<div id='board'>
  <div class='cell'></div>
  <div class='cell'></div>
  <div class='cell'></div>
</div>

div的宽度变化很好,但是高度(应该是屏幕的30%)实际上是线条.

The width of the divs is changing fine, but as for the height (which is supposed to be 30% of the screen each) are practically lines.

这可能不是必需的,但我感到很难过,如果您确实有所帮助,谢谢您抽出宝贵的时间. :)

This probably isn't necessary but I feel bad, if you do help out, thank you for taking your time. :)

推荐答案

那是因为您在木板上没有高度,几乎0的30%是... 0.

That is because you don't have a height to the board and the 30% of almost 0 is... 0.

为id为board的div添加一些高度.

Add some height to the div with the id of board.

将此添加到您的CSS:

Add this to your css:

html {
  background-color:black;
  color:white;
  text-align:center;
}
#board{
 height:300px;
}
.cell {
  border: 1px solid white;
  margin:1px;
  width:30%;height:30%;
}

这篇关于HTML不能更改Div的高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆