html - 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;
}```
解决方案
<!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 只是一个例子,你可以输入你想要的
推荐阅读
- java - 如何将嵌套或 JSON 对象保存在 spark 数据集中并转换为 RDD?
- c++ - 将私有对象变量与用户输入的变量进行比较
- c++ - 无法为在 neovim 中运行的程序提供输入
- java - 如何在 windowslistener 方法中调用 JFrame(类本身)?
- javascript - 当 validateFields 调用时,记录 2 个错误,当数据无效时(React,Antd)
- javascript - 如何从 Firebase Cloud Function 获取 JSON 数据
- jquery - 如何读取并显示单个通知?
- java - 如何使用 selenium webdriver 拖放 angularJS 元素
- kotlin - 用于集合的 MutableLiveData
- javascript - 使用关系从 Mysql 转换为 Mongo/mongoose