【问题标题】:ASP.NET MVC - Default Layout to Full ScreenASP.NET MVC - 默认布局为全屏
【发布时间】:2016-08-06 18:19:55
【问题描述】:

.net 框架、mvc 和 Visual Studio 的新手,所以这可能是一个简单的问题。无论出于何种原因,尽管经过数小时的反复试验,当使用使用新 MVC 应用程序创建的默认布局时,我仍无法让我的视图占据整个页面。

我尝试了各种 css 技巧来将元素扩展至 100% 的高度,但没有得到这样的运气。有没有办法使用引导程序来做到这一点?如果没有,关于如何在不影响引导程序的情况下执行此操作的任何建议?

通过实现“行”类,我已经能够获得跨越整个页面的宽度。这其中的高度部分仍然难以捉摸。

_layout.cshtml

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0">
    <title>@ViewBag.Title - Crestwood Weather</title>
    @Styles.Render("~/Content/css")
    @Scripts.Render("~/bundles/modernizr")
</head>

<body>
    <div class="navbar navbar-inverse navbar-fixed-top">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                @Html.ActionLink("Crestwood Weather Viewer", "Index", "Home", new { area = "" }, new { @class = "navbar-brand" })
            </div>
            <div class="navbar-collapse collapse">
                <ul class="nav navbar-nav">
                    <li>@Html.ActionLink("Home", "Index", "Home")</li>
                    <li>@Html.ActionLink("About", "About", "Home")</li>
                    <li>@Html.ActionLink("Contact", "Contact", "Home")            </li>
                </ul>
                @Html.Partial("_LoginPartial")
            </div>
        </div>
    </div>

    <div class="container-fluid body-content">
        @RenderBody()
        <hr />
        <footer>
            <p>&copy; @DateTime.Now.Year - Crestwood Midstream Partners LP</p>
        </footer>
    </div>

    @Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/bundles/bootstrap")
    @RenderSection("scripts", required: false)
</body>
</html>

视图的 HTML 和 Body 似乎仅限于布局中的某些内容,将其限制为页面高度的一半。即使在处理 HTML 和 Body 标签时,内容仍然显示如下。

示例

【问题讨论】:

    标签: asp.net-mvc twitter-bootstrap css


    【解决方案1】:

    您可以使用 boostrap 类“container-fluid”全屏显示。

    【讨论】:

      【解决方案2】:

      Content目录下有个site.css文件,在这个文件中修改max-width: 960px;

      【讨论】:

      • 哪个元素?为什么是宽度?为什么是 960 像素?在 HTML 和 Body 标签上尝试过,但没有成功。
      • 在 css 中的什么标签上?
      【解决方案3】:

      我想这会对你有所帮助..

      用javascript写这样的代码..

       <script>
      
          $(document).ready(function () {
              ResizeContentContainer();
      
          });
      
          window.onresize = ResizeContentContainer;
      
          function ResizeContentContainer() {
      
              var windowHeight = $(window).height();
              $(".body-content").outerHeight(windowHeight + "px");
          }
      </script>
      

      这将根据窗口向正文内容添加高度,当您重新调整大小时,它将自动计算正文内容的高度。

      【讨论】:

      • 这里也没有运气。使用谷歌开发者工具,我可以确认主体确实扩展到屏幕的整个高度,但内容保持在大约一半高度。
      猜你喜欢
      • 1970-01-01
      • 2019-08-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多