html - 是图像文件问题还是大小问题?HTML CSS 背景图片问题
问题描述
我一直在尝试使用不同的图像作为背景,但到目前为止我很不幸地确定这是照片文件大小的问题还是我使用的图片有问题?询问,因为我尝试使用一张图像并且背景图像显示并且可以工作,但是即使我已经多次查看我的代码并且它是正确的,我想要使用的任何其他图片都不会显示或正常工作。这是我当前的代码
<!DOCTYPE html>
<html>
<head>
<title>Winston Berz</title>
<style>
body {
background-image: url("C:\Users\apere\OneDrive\Desktop\HTML Progress\Winston Berz\All Photos\img5.jpg") no-repeat center center fixed;
min-height: 100%;
background-size: 100%;
}
</style>
</head>
<body>
<div id="Navbar">
<nav>
<a href="Main P.html">Main</a>
<a href="About me P.html">About Me</a>
<a href="Contact P.html">Contact</a>
<a href="Photos P.html">Photos</a>
</nav>
</div>
<div id="Main Title">
<header>
<h1>Winston Berz</h1>
</header>
</body>
</html>
还要注意的是,我也为 css 使用了单独的文档并得到了相同的结果,所以这次我求助于内部 css。帮助!请并谢谢你我对编码还是比较陌生。
解决方案
you could try to clear your browser cache (here is how) maybe the browser is storing previous images.
Also, you could consider creating a <div>
and place your background images there instead of setting the image inside css.
inside the <body>
tag you can add
<div class="background-images-wrapper">
<img src="image/link/path" alt="background1"><img>
</div>
and inside your css style sheet you add this
.background-images-wrapper{
height: 100%;
width: 100%:
object-fit: cover;
z-index: -1;
z-index: -1
is to make sure that your images will always stay behind the rest of your elements
推荐阅读
- python - 根据大小用颜色填充Python乌龟中的多边形
- vb.net - 如何使 MenuStrip 的样式与记事本中的 MenuStrip 一样?(VB.NET)
- javascript - Javascript - 通过功能使 html/bootstrap 按钮处于活动状态
- html - Regex to detect when certain characters or substrings
- php - 无法从 $wpdb 加载值
- xml - XML 验证器如何知道在哪里可以找到在 xml 文档中声明的模式实例以解析和使用 xsd?
- php - laravel上传新头像后如何删除旧头像?
- macos - 如何从局域网上的 Windows 10 家用电脑 RDP Ubuntu 16.04 和 OSX
- angular - 自定义验证器以检查密码是否在 Angular 6 和响应式表单中匹配
- python - 使用 Python 和 websocket-client 库发送安全 (SSL) Web 套接字请求,并希望更好地了解正在发生的事情