【问题标题】:My html not loading CSS file! It doesn't works [duplicate]我的 html 没有加载 CSS 文件!它不起作用[重复]
【发布时间】:2020-12-10 05:14:40
【问题描述】:

我正在制作一个 404 错误页面,我制作了一个 HTML 文件和一个 CSS 文件,但它无法正常工作。该文件在同一目录中,有人可以帮助我吗?请。谢谢 我尝试了几天,没有修复。谢谢 !任何帮助表示赞赏。

下面你可以看到代码。 我的 HTML 代码:

<!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
 <meta http-equiv="X-UA-Compatible" content="ie=edge">
 <link rel="stylesheet" href="./style.css">
 <title>Awesome 404 Error Page Design - Vikas Kukreti</title>
 <meta name="keywords" content="404, error, 404 error, 404 error page design, design, html, css, Vikas, Vikas kukreti" />
 <meta name="description" content="Awesome 404 error page design for 404 errors including cool looks and animations with HTML and CSS only. Developed with love ❤ by Vikas Kukreti" />
 
</head>
<body>
 
 <div id="particles" class="particles">
     <span></span>
     <span></span>
     <span></span>
     <span></span>
     <span></span>
     <span></span>
     <span></span>
     <span></span>
     <span></span>
     <span></span>
     <span></span>
     <span></span>
 </div>

 <main>
     <section>
         <h1>Page Not Found!</h1>
         <div>
             <span>4</span>
             <span class="circle">0</span>
             <span>4</span>
         </div>
         <p>We are unable to find the page.<br>you're looking for.</p>
         <div>
             <button>Back to mHome Page</button>
         </div>
     </section>
 </main>

</body>
</html>

我的 CSS 代码:

* {
    padding: 0;
    margin: 0;
}
body {
    background: radial-gradient( circle, rgb(28, 27, 90) 0%, rgb(15, 18, 44) 30%, rgb(15, 13, 31) 100%);
    height: 100vh;
    color: #efefef;
}
.particles {
    position: fixed;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
}
.particles span {
    position: absolute;
    top: 10%;
    left: 10%;
    display: block;
    content: '';
    width: 6px;
    height: 6px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 0.5rem;
    filter: blur(5px);

}
.particles span:nth-child(2) {
    top: 15%;
    left: 70%;
    filter: blur(3px);
}
.particles span:nth-child(3) {
    top: 70%;
    left: 40%;
    filter: blur(5px);
}
.particles span:nth-child(4) {
    top: 52%;
    left: 20%;
    filter: blur(4px);
}
.particles span:nth-child(5) {
    top: 74%;
    left: 90%;
    filter: blur(5px);
}
.particles span:nth-child(6) {
    top: 85%;
    left: 10%;
    filter: blur(7px);
}
.particles span:nth-child(7) {
    top: 67%;
    left: 79%;
    filter: blur(3px);
}
.particles span:nth-child(8) {
    top: 48%;
    left: 40%;
    filter: blur(4px);
}
.particles span:nth-child(9) {
    top: 45%;
    left: 30%;
    filter: blur(5px);
}
.particles span:nth-child(10) {
    top: 96%;
    left: 29%;
    filter: blur(4px);
}
.particles span:nth-child(11) {
    top: 55%;
    left: 89%;
    filter: blur(6px);
}
.particles span:nth-child(12) {
    top: 55%;
    left: 60%;
    filter: blur(7px);
}
main {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: cursive;
}
main h1{
    font-weight: normal;
}
main h1 {
    text-align: center;
    text-shadow: 0 0 5px #c3d168a2;
}
main div {
    margin-top: 2rem;
    text-align: center;
}
main div span{
    font-size: 5rem;
    line-height: 6rem;
    text-shadow: 0 0 7px #c3d168a2;
}
.circle {
    user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    -webkit-user-select: none;
    display: inline-block;
    position: relative;
    width: 6rem;
    height: 6rem;
    text-shadow: none;
    background: #e6f1a3 radial-gradient(#f9ffd2, #ecff70);
    color: rgba(0, 0, 0, 0);
    border-radius: 50%;
    box-shadow: 0 0 7px #e7f1a3a2;
}
.circle:after {
    display: block;
    position: absolute;
    content: '';
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-45deg);
    width: 10rem;
    height: 4rem;
    border-radius: 50%;
    border: 2px solid #fafafa;
    border-top: 0px solid #fafafa;
    border-bottom: 4px solid #fafafa;
    z-index: 2
}
.circle:before {
    display: block;
    position: absolute;
    content: '';
    top: 50%;
    left: 50%;
    background: #124;
    border-radius: 50%;
    width: 4px;
    height: 4px;
    transform-origin: 2.5rem 0;
    transform: translate(-2.5rem, 0) rotate(0deg);
    animation: circle-around 5s infinite linear;
}
@keyframes circle-around {
    0% { transform: translate(-2.5rem, 0) rotate(0deg); }
    100% { transform: translate(-2.5rem, 0) rotate(360deg); }
}
main p {
    margin-top: 3rem;
    text-align: center;
    text-shadow: 0 0 5px #c3d168a2;
}
main button {
    padding: 0.55rem 1.2rem;
    border: none;
    outline: none;
    appearance: none;
    border-radius: 1rem;
    background: rgb(17, 141, 44);
    color: #fafafa;
    box-shadow: 0 0 4px #e1f17859;
}
main button:hover {
    cursor: pointer;
}

请帮助为什么这不起作用?

【问题讨论】:

  • 你有我们可以看到的 Flask 代码吗?
  • 这里是@starkapi.errorhandler(404) def page_not_found(e): # 注意我们显式设置了404状态 return render_template('this.html'), 404
  • 能否分享您的 HTML 和 CSS 文件所在文件夹的屏幕截图

标签: python html css flask


【解决方案1】:

我测试了你的代码,它运行良好。我建议您尝试使用其他浏览器或尝试在浏览器中使用 Ctrl + F5 来强制更新。

【讨论】:

【解决方案2】:

尝试这样做...尝试删除“。”在你的href中

【讨论】:

  • 没有帮助。我试过但没有用,顺便说一句我在这里使用heroku:只需检查antispaminc.herokuapp.com/404
【解决方案3】:

您能否也从您的控制台发布任何消息。如果您使用的是 Chrome,请转到查看 -> 开发人员 -> 开发人员工具,点击控制台。如果您使用的是其他浏览器,请在此处查看如何打开它:https://balsamiq.com/support/faqs/browserconsole/

另外,请尝试在其他浏览器或隐身模式下加载您的网站。通常如果没有应用 CSS,它可能已被缓存,因此不会为您更新。

如果我有足够的声誉,我会发表评论。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2021-12-15
  • 2020-11-12
  • 2021-07-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-08-06
  • 2020-12-25
相关资源
最近更新 更多