首页 > 解决方案 > CSS背景不显示颜色

问题描述

我正在关注 YouTube 的教程。在那里,我遵循了相同的程序。我检查了几次。但是视频的作者背景颜色出现了,而我的没有。我尝试过溢出、清除等,但它不起作用。有大脑袋的人我需要帮助吗?

这是CSS代码:

*{
       
        margin: 0;
        padding: 0;
        font-family: sans-serif;
}

.container{

             width: 100%;
             height: 100%;
             background: #42455a;
}

这是html代码:

<!DOCTYPE html>
<html>
<head>
    <title>Crypto Currency Web App - Easy Tutorials</title>
    <link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
    <div class="container">
       
    </div>
</body>
</html>

编辑:问题已解决。解决方案是指定 html 和 body 高度

喜欢


              height:100%;
              padding:0;
              margin: 0;
}```

标签: htmlcss

解决方案


<!DOCTYPE html>
<html>
<head>
    <title>Crypto Currency Web App - Easy Tutorials</title>
    <link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
    <div class="container">
        <p> just write something to here your width and height percent not fixed size </p>
       
    </div>
</body>
</html>

如果你想查看容器,那么你的 CSS 应该如下:

.container{

             width: 100px;
             height: 100px;
             background: #42455a;
}

100 px 只是一个例子,你可以输入你想要的


推荐阅读