对 CSS 的更改未显示在 404 页面上
Changes to CSS not showing up on 404 page
对 CSS 文件所做的更改不会应用到 404 错误页面
编辑:有问题的页面:https://hinnahackers.no/404/
正确:这不是相对路径问题。我在 header 中指定一个基本 href,如下所示:
<base href="https://hinnahackers.no/">
我知道这行得通,因为我的 404 页面加载了我 CSS 文件中的一些样式,但不是新添加的 类.
这也不是强制刷新 CSS 文件问题,因为我已经在做 styles.css?v=X:
<link href="css/styles.css?v=749" rel="stylesheet" type="text/css" />
但它似乎在我的 404 页面上不起作用。 CSS 在其他页面上更新,例如 index.php.
这是我的 .htaccess 文件,如果用户输入无效 url:
,我会用它来将用户重定向到 404.php
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/$ .php
RewriteRule ^([^/]+)/([^/]+)/$ //.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ // [R=301,L]
#Rewrite everything to https
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
#404 redirect
ErrorDocument 404 /404.php
在我的 CSS 中添加了以下内容 类:
.404__heading {
font-size: 2em;
color: #fff;
line-height: 1.5;
}
.404__error {
margin-top: 50px;
font-size: 2em;
color: #ea0548;
line-height: 1.5;
}
.404__entry__container {
margin-top: 50px;
}
.404__entry__wrap {
position: relative;
display: inline-block;
height: 20px;
width: 21px;
vertical-align: middle;
margin-right: 12px;
}
.404__entry__wrap a {
display: inline-block;
vertical-align: middle;
color: #fff;
font-size: 2em;
text-decoration: none;
}
.404__entry__top__dot {
position: absolute;
top: 0;
left: 0;
background: #ff6600;
height: 7px;
width: 7px;
}
.404__entry__middle__dot {
position: absolute;
top: 10px;
left: 7px;
background: #ff6600;
height: 6px;
width: 7px;
transform: translateY(-50%);
}
.404__entry__bottom__dot {
position: absolute;
bottom: 0;
left: 0;
background: #ff6600;
height: 7px;
width: 7px;
}
.404__entry__caret {
display: inline-block;
vertical-align: middle;
background: #fff;
height: 35px;
width: 18px;
margin-bottom: -5px;
}
.404__heading::selection,
.404__error::selection,
.404__entry__wrap::selection,
.404__entry__wrap a::selection {
text-shadow: none;
background: rgba(255, 255, 255, 0.3);
color: #fff;
}
但我的 404.php 页面无法识别它们。所以现在我直接在我的 404 页面中添加了样式等。我对发生的事情完全不知所措。我已经用谷歌搜索了几个小时,但找不到解决方案。
您似乎有 CSS 个错误。
当您使用此工具检查 style.css 文件的 CSS 时:http://csslint.net/
您将看到 34 个错误。也许这就是导致您出现问题的原因?
CSS 类 不能以数字开头。
对 CSS 文件所做的更改不会应用到 404 错误页面
编辑:有问题的页面:https://hinnahackers.no/404/
正确:这不是相对路径问题。我在 header 中指定一个基本 href,如下所示:
<base href="https://hinnahackers.no/">
我知道这行得通,因为我的 404 页面加载了我 CSS 文件中的一些样式,但不是新添加的 类.
这也不是强制刷新 CSS 文件问题,因为我已经在做 styles.css?v=X:
<link href="css/styles.css?v=749" rel="stylesheet" type="text/css" />
但它似乎在我的 404 页面上不起作用。 CSS 在其他页面上更新,例如 index.php.
这是我的 .htaccess 文件,如果用户输入无效 url:
,我会用它来将用户重定向到 404.phpRewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/$ .php
RewriteRule ^([^/]+)/([^/]+)/$ //.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ // [R=301,L]
#Rewrite everything to https
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
#404 redirect
ErrorDocument 404 /404.php
在我的 CSS 中添加了以下内容 类:
.404__heading {
font-size: 2em;
color: #fff;
line-height: 1.5;
}
.404__error {
margin-top: 50px;
font-size: 2em;
color: #ea0548;
line-height: 1.5;
}
.404__entry__container {
margin-top: 50px;
}
.404__entry__wrap {
position: relative;
display: inline-block;
height: 20px;
width: 21px;
vertical-align: middle;
margin-right: 12px;
}
.404__entry__wrap a {
display: inline-block;
vertical-align: middle;
color: #fff;
font-size: 2em;
text-decoration: none;
}
.404__entry__top__dot {
position: absolute;
top: 0;
left: 0;
background: #ff6600;
height: 7px;
width: 7px;
}
.404__entry__middle__dot {
position: absolute;
top: 10px;
left: 7px;
background: #ff6600;
height: 6px;
width: 7px;
transform: translateY(-50%);
}
.404__entry__bottom__dot {
position: absolute;
bottom: 0;
left: 0;
background: #ff6600;
height: 7px;
width: 7px;
}
.404__entry__caret {
display: inline-block;
vertical-align: middle;
background: #fff;
height: 35px;
width: 18px;
margin-bottom: -5px;
}
.404__heading::selection,
.404__error::selection,
.404__entry__wrap::selection,
.404__entry__wrap a::selection {
text-shadow: none;
background: rgba(255, 255, 255, 0.3);
color: #fff;
}
但我的 404.php 页面无法识别它们。所以现在我直接在我的 404 页面中添加了样式等。我对发生的事情完全不知所措。我已经用谷歌搜索了几个小时,但找不到解决方案。
您似乎有 CSS 个错误。 当您使用此工具检查 style.css 文件的 CSS 时:http://csslint.net/ 您将看到 34 个错误。也许这就是导致您出现问题的原因?
CSS 类 不能以数字开头。