html - 为什么背景图像设置为空正文元素可见?
问题描述
If i would try to set a background image to empty div then the background image is not
visible.
So my question is: Why background image set to empty body element is visible?
Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Responsive Site</title>
<style>
*
{ /*CSS Reset*/
margin: 0px;
padding: 0px;
}
body
{
border:2px solid yellowgreen; /*body element do not contain any element and i am
setting background image to body element and apply
additional styling by selecting body element through element
selector.*/
background-image: url(images/backgroundimage.jpg);
background-repeat: no-repeat;
}
</style>
</head>
<body>
</body>
</html>
body 元素不包含任何元素,我将背景图像设置为 body 元素,并通过元素选择器选择 body 元素来应用其他样式。在上面的示例中,背景图像是可见的,并且正在移出 body 元素的框。为什么会这样?
解决方案
推荐阅读
- ios - 导航栏背景颜色
- r-markdown - 保持 pdf 文档中的块输出格式与控制台输出格式相同 - Rmarkdown
- flutter - 使用流进行优化
- git - 在分支中有同名文件夹时合并子模块
- bash - 在子shell中定义目录和子目录,简化
- reactjs - 错误:应用程序(...):渲染没有返回任何内容。这通常意味着缺少 return 语句。或者,不渲染任何内容,返回 null
- crafter-cms - CrafterCMS WebDAV 配置交付
- deep-learning - 在 colab 笔记本中设置 roBERTa 模型时出错
- google-sheets - 在数组公式中使用 INDIRECT
- ios - 无法在我的 iOS 设备中运行我的 Flutter 应用程序 - 无法注册 Bundle Identifier