gpt4 book ai didi

html - NGINX 不加载外部 css 文件

转载 作者:行者123 更新时间:2023-11-28 11:53:01 26 4
gpt4 key购买 nike

我创建了一个测试 html 页面,内联 javascript 和 css 工作正常。但是当引用外部 css 表时,它似乎没有加载。

/var/www/ME/test.html

    <html>
<head>
<link href="/test.css" type="text/css" rel="stylesheet" />
</head>

<body onload="javascript:alert('test');">
<div class="test">
<h1>Hi my name is tzvi</h1>
</div>
</body>
</html>

/var/www/ME/test.css

    .test {
color:"red";
}

/etc/nginx/nginx.conf

    user www-data;
worker_processes 4;
pid /var/run/nginx.pid;

events {
worker_connections 768;
# multi_accept on;
}

http {
include /etc/nginx/mime.types;
default_type text/html;

server {
listen 80; ## listen for ipv4; this line is default and implied
listen [::]:80 default ipv6only=on; ## listen for ipv6

error_log /var/log/nginx/file.log warn;

root /var/www/ME;
index index.php;

server_name localhost;

location / {
include /etc/nginx/mime.types;
try_files $uri $uri/ /index.php;
error_log /var/log/nginx/test.log warn;
}

location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
}
}
}

当我去 http://<webserver>/test.html我得到 javascript 弹出窗口和黑色文本。如果 css 可以正常工作,文本应该是红色的。

谢谢

最佳答案

将css文件改为

  .test {
color:red;
}

您应该在 css 中指明颜色名称,而不用双引号 ""

关于html - NGINX 不加载外部 css 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20222877/

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