英文:
Issue with background-image: in css
问题
我试图将一张图片添加到我的网站背景中,但似乎没有生效。
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="nav">
<h4 class="nav-text">USER</h4>
</div>
</body>
</html>
CSS
body {
background-color: black;
background-image: url("background.png");
}
.nav {
background-color: black;
opacity: 50%;
height: 45px;
}
.nav-text {
opacity: 100%;
color: white;
float: right;
margin-right: 25px;
margin-top: 12px;
}
我应该更改什么以使其显示图片而不是什么都不做?
英文:
I'm trying to add an image to the background of my website, and it isn't seeming to work. (Code is lacking because I am trying to get this to work first.
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="styles.css"/>
</head>
<body>
<div class="nav">
<h4 class="nav-text">USER</h4>
</div>
</body>
</html>
CSS
body {
background-color:black;
background-image: url("background.png")
}
.nav {
background-color: black;
opacity: 50%;
height: 45px;
}
.nav-text {
opacity: 100%;
color: white;
float: right;
margin-right: 25px;
margin-top: 12px;
}
What am I supposed to change to make it display the image rather than do nothing?
答案1
得分: 0
原来是浏览器缓存的问题,按下 CTRL + F5
解决了这个问题。
英文:
Turns out it was an issue with my browsers cache, pressing CTRL + F5
fixed the issue.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论