我创建了一个测试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有效,则文本应为红色。
由于
答案 0 :(得分:0)
将css文件更改为
.test {
color:red;
}
您应该在css中指明颜色名称而不包含双打引号""
。