在 Razor Pages Identity“管理帐户”页面上设置背景图像

问题描述 投票:0回答:1

我正在尝试在 ASP.NET Core Web 应用程序的登录和管理帐户页面上设置背景图像 - 我正在使用 Razor Pages 身份,但无论我将 CSS 放在哪里,它似乎都不会改变。

我尝试将其放在登录页面本身以及网站 CSS 上,但仍然没有任何效果。

它在我的其他页面上有效,但在这些页面上无效。

我的CSS如下:

body{
    background-image: url('hero-range-1.jpg');
    height: 100%;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
}
c# css asp.net-core razor-pages
1个回答
2
投票

由于注销页面在身份区域下,所以背景图片的url将是

/Identity/hero-range-1.jpg
,所以你需要将图片放入
wwwroot/Identity
,这里是一个演示:

图像根:

/wwwroot/Identity/hero-range-1.jpg

区域/身份/页面/帐户/Login.cshtml:

...
<style>
    body{
        background-image: url('../hero-range-1.jpg');
        height: 100%;
        background-position: center;
        background-repeat: no-repeat;
        background-size: cover;
    }
</style>
© www.soinside.com 2019 - 2024. All rights reserved.