ASP.NET Core 8 MVC。为什么当我将 <main> 元素从 _layout.cshtml 移动到 index.cshtml 时会破坏 css

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

当我将元素从 _Layout.cshtml 文件移动到 ASP.NET Core MVC 项目中的 Index.cshtml 文件时,它破坏了 CSS 样式。但是当我将元素移回具有完整 html 结构的 Layout.cshtml 时,工作正常。 所有的样式都在 Bootstrap 中。

提前致谢

如果 ASP.NET Core MVC 项目主要使用 Bootstrap 类进行样式设置,则将元素从 _Layout.cshtml 文件移动到 Index.cshtml 文件通常不会导致 CSS 样式问题,因为 Bootstrap 类被设计为响应式的,并且应该适应 HTML 结构的变化。

asp.net asp.net-mvc asp.net-core
1个回答
0
投票

我找到了解决方案 xD 问题出在这里:

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

新版本:

<div>
    <main>
        @RenderBody()
    </main>
</div>
© www.soinside.com 2019 - 2024. All rights reserved.