为什么我设置了表格的背景颜色无效果呢

来源:3-2 项目作业

张凤梅

2020-01-12 16:23:21

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <link rel="stylesheet" type="text/css" href="index.css">
</head>
<body>
    <table>
        <!-- 头部 -->
        <thead>
            <img src="img/logo.png">
        </thead>
        <!-- 主体 -->
        <tbody>
            <!-- 左侧 -->
            <table class="left"></table>
            <!-- 右侧 -->
            <table class="right"></table>
        </tbody>
        <!-- 底部 -->
        <tfoot></tfoot>
    </table>
</body>
</html>
*{margin:0;padding:0;}
table{
    width: 100%;
}
thead{
    width: 100%;
    height: 60px;
    background-color:#169bd5;
/*}
thead>img{
    padding-top:10px;
    color: white;
}
tbody{
    width: 100%;
}
tbody>.left{
    width: 12%;
}
tbody>.right{
    width: 88%;
}
tfoot{
    width: 100%;
    background:#169bd5;
}*/


写回答

1回答

好帮手慕慕子

2020-01-12

同学你好,因为html标签嵌套不规范,导致浏览器解析异常,所以设置了背景颜色没有生效。

建议: 严格按照table> thead/tbody/tfoot > tr > td/th 这个嵌套规则, 在td下嵌套其他内容。

http://img.mukewang.com/climg/5e1ae7ec0962c04a07500651.jpg

如果我的回答帮助到了你,欢迎采纳,祝学习愉快~

0

0 学习 · 40143 问题

查看课程