html相对地址到css样式表不起作用

时间:2017-10-03 21:35:36

标签: html css hyperlink relative

对于覆盆子pi上的apache服务器,我有一个如下的linux文件夹结构:

/var/www/html/index.html
/var/www/css/style.css
/var/www/php/someCode.php

index.html如下:

<!DOCTYPE html>
<html>
<head>
 <title>Introducing CSS Not Working</title>
 <link href="../css/style.css" type="text/css"
 rel="stylesheet" />
</head>
<body>
 <h1>From Garden to Plate Not Working</h1>
 <p>A <i>potager</i> is a French term for an
 ornamental vegetable or kitchen garden ... </p>
 <h2>What to Plant</h2>
 <p>Plants are chosen as much for their functionality
 as for their color and form ... </p>
</body>
</html>

style.css如下:

body {
font-family: Arial, Verdana, sans-serif;}
h1, h2 {
color: red;}
p {
color: #665544;}

css不影响html。您知道为什么,我猜测index.html中的css链接有什么问题吗?感谢。

1 个答案:

答案 0 :(得分:0)

css文件超出了根目录,我将它移动到index.html所在的同一目录中,或者如果你需要css文件夹,我会像这样创建它们

/var/www/index.html
/var/www/css/style.css 
/var/www/php/someCode.php