gpt4 book ai didi

html - 在 CSS 中本地链接 url()

转载 作者:太空宇宙 更新时间:2023-11-04 03:57:04 25 4
gpt4 key购买 nike

我正在尝试为我的网页获取背景图片。我有一个外部样式表的链接,它工作正常(适用 CSS),但是当我尝试使用 background-image 获取背景图像时,它没有显示结果。我已经尝试了绝对和相对 URL

HTML:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="generator" content="CoffeeCup HTML Editor (www.coffeecup.com)">
<meta name="created" content="Wed, 26 Mar 2014 04:01:34 GMT">
<meta name="description" content="">
<meta name="keywords" content="">
<title>Welcome to CSS</title>
<link rel="stylesheet" type="text/css" href="welcome.css" />
</head>
<body></body>
</html>

CSS:

body{
background-image:url('C:\Users\Neo\Documents\CoffeeCup Software\My
Website\Files\images.jpg');
background-repeat:repeat-x;
}

最佳答案

您不能从本地设置绝对路径。您可以只设置绝对路径的实时网页。以下方式,

 BODY { background-image: url(http://www.bg.com/pinkish.gif) }

另一种设置相对路径的方法。我假定您的网站根文件夹

 __My Website
|__Files
|__images.jpg
|__welcome.css
|__welcome.html

它是相对于样式表的,但我建议使 url 相对于你的 url,基于上面的 strutted set relative path 以下方式,

 background-image:url('Files/images.jpg');

关于html - 在 CSS 中本地链接 url(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22651760/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com