【发布时间】:2018-12-20 09:03:25
【问题描述】:
我有这个简单的 html 代码。我只是想格式化颜色,但实际上没有一个 CSS 正在格式化它。
我尝试更改变量名称,将表类更改为 id,反之亦然。
<head>
<style>
.cool-table {
width: 500px;
border: 1px solid #000;
background-color: blue;
color: purple;
}
.cool-table tr:first-child td {
font-size: 30px;
background-color: red;
color: green;
}
#cell-style {
font-size: 8px;
text-align: left;
}
</style>
</head>
<html>
<body>
<table class="cool-table">
<tr>
<th id="cell-style">Fruit</th>
<th id="cell-style">Price</th>
</tr>
<tr>
<th id="cell-style">Apples</th>
<th id="cell-style">$10</th>
</tr>
<tr>
<th id="cell-style">Banana</th>
<th id="cell-style">$50</th>
</tr>
<tr>
<th id="cell-style">Mango</th>
<th id="cell-style">$20</th>
</tr>
</table>
</body>
</html>
它应该将整个表格背景显示为蓝色,文本应该是紫色。第一行的文本应该很大,带有红色背景和绿色文本。其余单元格应为蓝色背景,带有紫色文本,字体大小为 8px。
【问题讨论】:
-
您需要将表格包装在
<body>元素中.. 并将您的<style>包装在<head>元素中,内部 @987654326 之前的<html>标签@
标签: html css html-table