【问题标题】:Resource blocked due to MIME-type conflict ("application/json") (X-Content-type-options: nosniff)由于 MIME 类型冲突(“application/json”)而被阻止的资源(X-Content-type-options: nosniff)
【发布时间】:2021-09-10 14:07:31
【问题描述】:

我刚刚为我的团队和我正在实施的 Web 应用程序设计了一个页脚。当我加载 html 文件并访问它们时,页脚看起来很好。 但是,当我的一位队友这样做时,页脚根本没有样式属性,而是出现在页面的右侧。

调试起来相当困难,因为它适用于我,但我收到了标题中的错误消息。

这是我的 html 代码:

<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="generator" content="Hugo 0.83.1">

    <title>Central SignIn</title>

    <link rel="canonical" href="https://getbootstrap.com/docs/5.0/examples/sign-in/">

    <link rel="stylesheet"
          href=
                  "https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha1/css/bootstrap.min.css"
          integrity=
                  "sha384-r4NyP46KrjDleawBgD5tp8Y7UzmLA05oM1iAEQ17CSuDqnUK2+k9luXQOfXJCJ4I"
          crossorigin="anonymous" />
    <script src=
                    "https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"
            integrity=
                    "sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo"
            crossorigin="anonymous"></script>
    <script src=
                    "https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha1/js/bootstrap.min.js"
            integrity=
                    "sha384-oesi62hOLfzrys4LxRF63OJCXdXDipiYWBnvTl9Y9/TRlw5xlKIEHpNyvvDShgf/"
            crossorigin="anonymous"></script>

    <link rel="stylesheet" type="text/css" href="footerSmallPage.css" media="all">
    <!-- Bootstrap core CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" rel="stylesheet"
          integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">

    <!-- Custom styles for this template -->
    <link href="https://getbootstrap.com/docs/5.0/examples/sign-in/signin.css" rel="stylesheet">
</head>
<body class="text-center">

<main class="form-signin">

    <form name="f">
        <h1 class="h3 mb-3 fw-normal">Central Service Sign in</h1>

        <!-- Email input field -->
        <div class="form-floating">
            <input name= "username" type="email" class="form-control"
            id="floatingInput"
                   placeholder="name@example.com">
            <label for="floatingInput">Email address</label>
        </div>

        <!-- Password input field -->
        <div class="form-floating">
            <input name="password" type="password" class="form-control"
                   id="floatingPassword" placeholder="Password">
            <label for="floatingPassword">Password</label>
        </div>

        <!-- Login button -->
        <button class="w-100 btn btn-lg btn-primary" type="submit">Sign in</button>

    </form>

    <form action="/home" method="get">
        <input type="submit" name="Go to the overview" id="overviewButton" />
    </form>
        <!-- Button for Navigation - Opens modal on click -->
            <button type="button"
                    class="btn btn-dark al"
                    data-toggle="modal"
                    data-target="#navigation">
                Navigation
            </button>

    <!-- Modal initialization -->
    <div class="modal fade"
         id="navigation">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h2 class="modal-title">
                        Navigation</h2>
                    <button type="button"
                            class="close"
                            data-dismiss="modal"
                            aria-label="Close">
                            <span aria-hidden="true">
                              X</span>
                    </button>
                </div>
                <!--Modal Text-->
                <div class="modal-body">
                    <p style="font-size:20px"> Copyright © 2021 </p>
                    <p> Gruppe20 Web & Data Engineering </p>
                    <p> All rights reserved. </p>
                    <br>
                    <p style="font-size:20px;"> <h3> Authors: </h3> </p>
                    <p> Emily Vorderwuelbeke </p>
                    <p> Severin Burghart </p>
                    <p> Ludwig Loggenkamp </p>
                </div>
                <div class="modal-footer">

                </div>
            </div>
        </div>
    </div>

</main>
<footer class="footer">
    <br>
    <br>
    <p> Copyright © 2021 - Gruppe20 Web & Data Engineering - All rights reserved </p>
    <p> Authors: Emily Vorderwuelbeke - Severin Burghart - Ludwig Roggenkamp</p>
</footer>
</body>
<script>
    function handleSubmit(event) {
        event.preventDefault();
        const data = new FormData(event.target);
        const value = Object.fromEntries(data.entries());

        const options = {
            method: 'POST',
            body: JSON.stringify(value)
        };
        console.log(value);
        console.log(options)
        fetch( 'login', options )
            .then( response => document.cookie =
                "Authorization="+response.headers.get("Authorization")+";path=/;expiration=0;");

    }
    const form = document.querySelector('form');
    form.addEventListener('submit', handleSubmit);

</script>
</html>

这里是css文件(它与html页面在同一个文件夹中)

@media screen and (max-width: 768px) {
    .footer{
        visibility: hidden;
        display: none;
    }
}

.footer {
    position: absolute;
    bottom: 0;
    padding-bottom: 100px;
    width: 100%;
    overflow: hidden;
    color: black;
    height: 177px;
    text-align: center;
    background-image: url(footer-image.jpg);
    background-repeat: no-repeat;
    background-size: 100% 100%;
}

【问题讨论】:

    标签: html css footer


    【解决方案1】:

    您在此处指定了错误的文件路径。

    <link rel="stylesheet" type="text/css" href="footerSmallPage.css" media="all">
    

    实际上会这样:

    <link rel="stylesheet" type="text/css" href="./footerSmallPage.css" media="all">
    

    【讨论】:

    • 您可能显示了错误的文件路径。你能显示文件夹构建吗?
    • 所以你的意思是你的队友在页面加载过程中遇到了错误?我照原样复制了您的代码,但无法复制问题,CSS 正在像往常一样加载。
    • @ercüment 我现在更改了它,因此 css 位于 html 文件中。样式现在可以使用,并且当通过 IntelliJ 按钮以 chrome 显示文件时,它也可以与背景一起使用。但是,当我启动服务器时,样式是正确的,但缺少背景图像。
    • @sas 正确。现在我也收到错误消息,即通过 url 访问服务器时没有加载背景图像,而不仅仅是通过 IntelliJ chrome 快捷方式显示 html 文件
    猜你喜欢
    • 2021-01-10
    • 2020-11-13
    • 2020-08-10
    • 2018-01-13
    • 2019-11-04
    • 1970-01-01
    • 2020-03-07
    • 2023-03-20
    • 1970-01-01
    相关资源
    最近更新 更多