样式不适用于所有ASP.NET MVC4 Internet应用程序视图 [英] Styles not working on all ASP.NET MVC4 Internet application views

查看:83
本文介绍了样式不适用于所有ASP.NET MVC4 Internet应用程序视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我按照此处的步骤创建了一个ASP.NET MVC4应用程序: http://www.asp.net/mvc/tutorials .一切都在使用默认样式.然后,通过删除我认为不必要的内容并放入一些引导程序来更改_Layout.cshtml页面.它可以很好地在首页上显示页面(从数据库)显示项目列表,但是创建,编辑,删除和显示页面(自动生成)以及我尝试创建的所有页面都无法使用更新了样式.他们可以看到布局页面,因为其中有文本,但是没有设置样式.有趣的是,如果我添加一个按钮并设置类,那么它将看起来像引导按钮.我不确定要包含什么代码.知道会是什么吗?

I created an ASP.NET MVC4 application following the steps here: http://www.asp.net/mvc/tutorials. Everything was working with the default styles. Then I changed the _Layout.cshtml page by deleting whatever I thought was unnecessary and putting in some bootstrap. It works beautifully for the home page the page that displays the list of items (from the database), but the create, edit, delete and display pages (auto-generated) as well as any pages I try so create now aren't being updated with the styles. They can see the layout page because the text is there but they aren't styled. Funny enough though, if I add a button and set the class then it will look like the bootstrap button. I'm not sure what code to include. Any idea what it could be?

<!DOCTYPE html>
    <head>
    <meta name="viewport" content="width=device-width" />

    @Styles.Render("~/Content/css")
    @Scripts.Render("~/bundles/modernizr")

    <script type="text/javascript" src="@Url.Content("~/Scripts/jquery-1.9.1.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/Scripts/bootstrap.min.js")"></script>
    <link href="~/Content/bootstrap/bootstrap.css" rel="stylesheet" />

    <link rel="stylesheet" type="text/css" href="css/style.css" media="screen" />
    <link rel="stylesheet" type="text/css" href="css/layout.css" media="screen" />

</head>

<body id="body" style="background-color: transparent !important;">
<form id="form1" method="post" runat="server" enctype="multipart/form-data" class="form-horizontal">
    <div id="wrap">
        <div id="topbar">
            <div id="appTitle">
                <a href="default.aspx">Online Applications</a>
            </div>
            <div class="roundcont">
                <div class="roundtop">
                    <img src="images/tl.gif" alt="" width="8" height="8" class="corner" style="display: none" />
                </div>
            </div>
            <div style="margin-left: 260px; background-color: white;" id="logoScroll">
</body> 

推荐答案

更改:

<link href="~/Content/bootstrap/bootstrap.css" rel="stylesheet" />

收件人:

<link href="/Content/bootstrap/bootstrap.css" rel="stylesheet" />

ASP.net形式的波浪号表示根目录.我不认为MVC这样解析,所以我想那是您的问题.

The tilde in ASP.net forms means root directory. I don't think MVC parses it at such so I imagine that is your problem.

摆脱它,看看会发生什么:-)

Get rid of it and see what happens :-)

这篇关于样式不适用于所有ASP.NET MVC4 Internet应用程序视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆