How can I make an HTML <button>
vertifically fill a Table Cell with CSS?
如何使HTML
I can use width:100%
to make the button horizontally fill a Table Cell with CSS, but height:100%
doesn't do anything.
我可以使用宽度:100%使按钮水平填充带有CSS的表格单元格,但高度:100%不执行任何操作。
For an example, please see: http://jsfiddle.net/eA5fQ/
有关示例,请参阅:http://jsfiddle.net/eA5fQ/
Thanks!
谢谢!
4 个解决方案
#1
4
You'll need to specify the height in pixels as in:
您需要以像素为单位指定高度:
height: 100px;
#2
4
If you don't mind a jQuery solution:
如果您不介意jQuery解决方案:
$('#button1').css('height', $('#button1').parent('td').height());
现场演示
#3
4
Add height:100%;
to your button and set height of your td tag in percents
加高度:100%;到你的按钮并设置你的td标签的高度百分比
#4
-1
If you use min-height: 1px;
as well as height: 100%;
it seems to work fine: http://jsfiddle.net/jJbCd/8/
如果你使用min-height:1px;以及身高:100%;它似乎工作正常:http://jsfiddle.net/jJbCd/8/
#1
4
You'll need to specify the height in pixels as in:
您需要以像素为单位指定高度:
height: 100px;
#2
4
If you don't mind a jQuery solution:
如果您不介意jQuery解决方案:
$('#button1').css('height', $('#button1').parent('td').height());
现场演示
#3
4
Add height:100%;
to your button and set height of your td tag in percents
加高度:100%;到你的按钮并设置你的td标签的高度百分比
#4
-1
If you use min-height: 1px;
as well as height: 100%;
it seems to work fine: http://jsfiddle.net/jJbCd/8/
如果你使用min-height:1px;以及身高:100%;它似乎工作正常:http://jsfiddle.net/jJbCd/8/