问题描述 投票:0回答:0

body { width: 100%; margin: 0 auto; background-image: url(/images/background.jpg); background-repeat: repeat; background-attachment: fixed; }

index.html
在Web应用程序的根源中:

index.html
styles
   -- main_style.css
images
   -- background.jpg

我在URL

中尝试过有没有空间的尝试 我尝试过有没有单语句的尝试
我尝试了几个不同的URL:
url('images/background.jpg'); url('/images/background.jpg'); url('../images/background.jpg');


没有这些工作。
当我使用WebStorm,甚至我只是打开
index.html
    时,这是不起作用的。如果我确实转到链接
  • file:///C:/Users/tom/git/htmx-demo-frontend-javascript/images/background.jpg
  • ,那么我可以在浏览器中看到图像。
  • 至少对于您的HTML,您需要在CSS链接中具有一个
    .
    。正确的链接看起来像这样:
<link rel="stylesheet" href="./styles/main_style.css">

我不确定图像,但是我假设您还需要在CSS文件的链接到图像中的一个。

javascript html css
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.