首页 > 解决方案 > MVC 给 Identity/Account/Login 和 Identity/Account/Register Views 一个不同的 _Layout 页面

问题描述

我想将不同的 css 应用于页面正文加载到 MVC 堆栈中的默认 _Layout 文件中的位置。这是我希望在登录和注册页面中采用不同样式的部分。

<main role="main" class="container pb-3">
    @RenderBody()
</main>

对于登录和注册页面,我希望这部分是这样的:

<main id="loginorregister" role="main" class="container pb-3">
    @RenderBody()
</main>

因为新的id标签。我可以在wwwroot/css/site.css. 我可以将此样式应用于“loginorregister”id 标签。

#loginorregister {
  position: relative;
  height: 100vh;
  overflow: auto;
  background-image: url("../img/pic.jpg");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
}

如您所见,布局页面看起来会有所https://localhost:5001/Identity/Account/Register不同https://localhost:5001/Identity/Account/Login

我该怎么做?

标签: c#htmlcssasp.net-mvcentity-framework

解决方案


推荐阅读