Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/301.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 尝试在MVC4 Web应用中获取容器外部的页脚_C#_Html_Css_Asp.net Mvc 4 - Fatal编程技术网

C# 尝试在MVC4 Web应用中获取容器外部的页脚

C# 尝试在MVC4 Web应用中获取容器外部的页脚,c#,html,css,asp.net-mvc-4,C#,Html,Css,Asp.net Mvc 4,本质上,当使用Visual Studio 2017创建MVC 4应用程序时,页脚被约束在一个div中,该div在_layout.cshtml中有一个类容器主体内容。当然,这会使页脚约束在div中: 但是我们想要的是页脚扩展页面的整个宽度,就像页眉一样 当我把div注释掉的时候 页脚获得100%的宽度,但现在正文中的其他所有内容也获得100%的宽度: 在页脚下还有一堆空白。以下是_layout.cshtml的完整代码: <!DOCTYPE html> <html> &

本质上,当使用Visual Studio 2017创建MVC 4应用程序时,页脚被约束在一个div中,该div在_layout.cshtml中有一个类
容器主体内容
。当然,这会使页脚约束在div中:

但是我们想要的是页脚扩展页面的整个宽度,就像页眉一样

当我把div注释掉的时候

页脚获得100%的宽度,但现在正文中的其他所有内容也获得100%的宽度:

在页脚下还有一堆空白。以下是_layout.cshtml的完整代码:

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

</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top" id="navbar-gradient">
    <div class="container">
        <div class="navbar-header">
            <!--<img src="~/images/lion-logo.png" />-->
            <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>
            <img src="~/images/lion-logo.png" id="logo"/>
                @Html.ActionLink("LION TECHNOLOGIES", "Index", "Home", new { area = "" }, new { @class = "navbar-brand", @id = "logo-text" })
        </div>
        <div class="navbar-collapse collapse" id="navbar-gradient">
            <!--hide links-->
            <ul class="nav navbar-nav" id="hidden">
                <li>@Html.ActionLink("Reports", "Index", "Home")</li>
                <li>@Html.ActionLink("Accounts", "About", "Home")</li>
                <li>@Html.ActionLink("Settings", "Contact", "Home")</li>
            </ul>
            @Html.Partial("_LoginPartial")
        </div>
    </div>
</div>

   <!-- <div class="container body-content">-->
    @RenderBody()
    <!--<hr />-->
    <footer>
        <p>&copy; @DateTime.Now.Year - <img src="~/images/lion-logo.png" id="logo-footer" /> LION TECHNOLOGIES</p>
    </footer> 
    <!--</div>-->

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

</body>
</html>

@ViewBag.Title-我的ASP.NET应用程序
@style.Render(“~/Content/css”)
@Style.Render(“~/Content/Style.css”)
@Scripts.Render(“~/bundles/modernizer”)
@ActionLink(“狮子科技”、“索引”、“主页”、新{area=”“}、新{@class=“navbar品牌”、@id=“logo text”})
  • @ActionLink(“报告”、“索引”、“主页”)
  • @ActionLink(“账户”、“关于”、“主页”)
  • @ActionLink(“设置”、“联系人”、“主页”)
@Html.Partial(“_LoginPartial”) @RenderBody() &抄袭@DateTime.Now.Year-狮子科技

@Scripts.Render(“~/bundles/jquery”) @Scripts.Render(“~/bundles/bootstrap”) @RenderSection(“脚本”,必需:false)

我还尝试过用
容器主体内容
div将所有内容包装在
标记中,但没有任何效果。还有其他建议吗

如果您使用的是bootstrap 3,那么请尝试从包含类容器的div中删除页脚,然后使用类continer流体创建另一个div after,并将页脚代码放入其中
.container
为固定宽度,
.container fluid
为全宽。请参见bootstrap 3的网格系统


@RenderBody()

&抄袭@DateTime.Now.Year-狮子科技

因为我还是C#新手,所以我没有意识到,
@RenderBody()
这行代码可以单独渲染整个身体部分。我所需要做的就是:

<div class="container body-content">
    @RenderBody()
    <!--<hr />-->
</div>
    <footer>
        <p>&copy; @DateTime.Now.Year - <img src="~/images/lion-logo.png" id="logo-footer" /> LION TECHNOLOGIES</p>
    </footer>     

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

</body>
</html>

@RenderBody()
&抄袭@DateTime.Now.Year-狮子科技

@Scripts.Render(“~/bundles/jquery”) @Scripts.Render(“~/bundles/bootstrap”) @RenderSection(“脚本”,必需:false)

@RenderBody()

@HappyHands31之后关闭div如果它对您有用,那么您可以将它标记为答案吗?
<div class="container body-content">
    @RenderBody()
    <!--<hr />-->
</div>
    <footer>
        <p>&copy; @DateTime.Now.Year - <img src="~/images/lion-logo.png" id="logo-footer" /> LION TECHNOLOGIES</p>
    </footer>     

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

</body>
</html>