[英]CSS background property not working with wamp64
I am trying to add a hero image to my website.我正在尝试向我的网站添加英雄形象。 I have the image ready and in my desired location, but cannot set it as a background image for the hero div.我已准备好图像并位于所需位置,但无法将其设置为英雄 div 的背景图像。 I'm using wampserver64.我正在使用 wampserver64。
I have tried using the background
property shorthand, but have resorted to using background-image
, background-size
tags etc.我尝试使用background
属性简写,但求助于使用background-image
、 background-size
标签等。
Here are the relevant parts of my code:以下是我的代码的相关部分:
The links in <head>
<head>
中的链接
<link rel="stylesheet" href="styles/12cols.css" type="text/css"media="screen">
<link rel="stylesheet" href="styles/styles.css" type="text/css"media="screen">
<div class="hero">
<h1>Placeholder</h1>
</div>
CSS: CSS:
.hero {
background-image: url("../assets/hero-image.png");
background-position: center;
background-size: 100% auto;
background-repeat: no-repeat;
}
And my folder structure is as follows:我的文件夹结构如下:
project
-assets
-fonts
font.ttf (etc)
-hero-image.png
-styles
-12cols.css
-styles.css
-index.php
-login.php
-signup.php
I don't get any error messages except for GET http://project/favicon.ico 404 (Not Found)
我没有收到任何错误消息,除了 GET http://project/favicon.ico 404 (Not Found)
UPDATE: Tried testing as an HTML file without using wampserver, but still with no avail.更新:尝试在不使用 wampserver 的情况下以 HTML 文件的形式进行测试,但仍然无济于事。
Also adding a height and width specification to make it look like this:还添加了高度和宽度规范,使其看起来像这样:
.hero {
background-image: url("../assets/hero-image.png");
background-position: center;
background-size: 100% auto;
background-repeat: no-repeat;
width: 100%;
height: 1200px;
}
hasn't helped either.也没有帮助。
IMG and CSS are not visible because they are in the same directory. IMG 和 CSS 不可见,因为它们在同一个目录中。 Try deleting assets .尝试删除资产。
background-image: url("../hero-image.png");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.