CSS文件未包含在剃须刀页面中

发布于 2025-02-08 14:07:27 字数 871 浏览 1 评论 0原文

我是Razor页面概念的初学者。我开始在已经存在的项目中添加剃须刀页面。这是一个主页,我应该从头开始路由。我添加了CSS文件的链接,但不包括在内。我真的不知道为什么会发生这种情况。我确定路径是正确的,我将它们正确地定位在wwwroot中。几天前,我被困在那个。有什么想法,为什么会发生这种情况?

@model MyProject.Area
@{
    Layout = null;
}

<!DOCTYPE html>
<html class="fullpagehight">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css" />
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Raleway" />
    <link href="~/lib/bootstrap/css/bootstrap.css" rel="stylesheet" />
</head>
<body class="fonttypeformat fullpagehight">

    <div id="mainSection" class="bgimg w3-display-container w3-animate-opacity w3-text-white">
    </div>
</body>
</html>

I am beginner in Razor pages concepts. I started to add a razor page in an already existing project. It's a home page and I should be routed to it on start. I added a link for css files but they are not included. I really don't have an idea why this happen. I am sure that the paths are right and I located them properly in the wwwroot. I am stuck on that few days ago. Any thoughts why might this happen?

@model MyProject.Area
@{
    Layout = null;
}

<!DOCTYPE html>
<html class="fullpagehight">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css" />
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Raleway" />
    <link href="~/lib/bootstrap/css/bootstrap.css" rel="stylesheet" />
</head>
<body class="fonttypeformat fullpagehight">

    <div id="mainSection" class="bgimg w3-display-container w3-animate-opacity w3-text-white">
    </div>
</body>
</html>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

A君 2025-02-15 14:07:27

您需要更改:

<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Raleway" />
<link href="~/lib/bootstrap/css/bootstrap.css" rel="stylesheet" />

to:

<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Raleway">
<link href="~/lib/bootstrap/css/bootstrap.css" rel="stylesheet">

没有 /在决赛中。希望我能帮助你。周末愉快。

问候

You need to change:

<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Raleway" />
<link href="~/lib/bootstrap/css/bootstrap.css" rel="stylesheet" />

To:

<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Raleway">
<link href="~/lib/bootstrap/css/bootstrap.css" rel="stylesheet">

Without / in the final. Hope I helped you. Have a wonderful weekend.

Regards

画离情绘悲伤 2025-02-15 14:07:27

恐怕CSS的路径不正确。bootstrap.css文件默认情况下是/lib/bootstrap/dist/dist/css by默认

<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css" />

情况正确。

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            ...
            app.UseHttpsRedirection();
            

            app.UseStaticFiles();

            app.UseRouting();

            ...
        }

I'm afraid maybe the path of css is not correct.The bootstrap.css file is in /lib/bootstrap/dist/css by default.So the css reference will be like:

<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css" />

If the paths are correct.Try to make sure the project contains app.UseStaticFiles(); in Startup.cs like this:

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            ...
            app.UseHttpsRedirection();
            

            app.UseStaticFiles();

            app.UseRouting();

            ...
        }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文