但是,它工作正常,但不适用于
请注意,我提供了没有
几天前我问了一个问题,我不能在标签<td>
内增加元素的高度。然后,有人建议我应该像这样尝试CSS文件:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Stack Overflow</title>
<style>
html,
body,
table {
height: 100%;
width: 100%;
}
p {
display: inline-table;
padding: 0px;
margin: 0px;
height: 100%;
width: 100%;
background-color: chartreuse;
}
</style>
</head>
<body>
<table border="1">
<tr>
<td>
<p>Hello World</p>
</td>
<td>
<p>Hello World</p>
</td>
<td>
<p>Hello World</p>
</td>
<td>
<p>Hello World</p>
</td>
<td>
<p>Hello World</p>
</td>
</tr>
</table>
</body>
</html>
但是,它工作正常,但不适用于<button>
元素。
我怎样才能为<button>
元素做到这一点???
请注意,我提供了没有<button>
元素的代码段
您可以通过为button
指定宽度和高度来执行此操作,就像在<p>
元素中指定它
一样
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Stack Overflow</title>
<style>
html,
body,
table {
height: 100%;
width: 100%;
}
p {
display: inline-table;
padding: 0px;
margin: 0px;
height: 100%;
width: 100%;
background-color: chartreuse;
}
button {
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<table border="1">
<tr>
<td>
<button>Hello this is the new button</button>
</td>
<td>
<p>Hello World</p>
</td>
<td>
<p>Hello World</p>
</td>
<td>
<p>Hello World</p>
</td>
<td>
<p>Hello World</p>
</td>
</tr>
</table>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Stack Overflow</title>
<style>
html,
body,
table {
height: 100%;
width: 100%;
}
button {
display: inline-table;
padding: 0px;
margin: 0px;
height: 100%;
width: 100%;
background-color: chartreuse;
}
</style>
</head>
<body>
<table border="1">
<tr>
<td>
<button>Hello World</button>
</td>
<td>
<button>Hello World</button>
</td>
<td>
<button>Hello World</button>
</td>
<td>
<button>Hello World</button>
</td>
<td>
<button>Hello World</button>
</td>
</tr>
</table>
</body>
</html>