Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/73.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
Html site.css未覆盖.field验证的bootstrap.css错误_Html_Css_Asp.net Mvc_Twitter Bootstrap - Fatal编程技术网

Html site.css未覆盖.field验证的bootstrap.css错误

Html site.css未覆盖.field验证的bootstrap.css错误,html,css,asp.net-mvc,twitter-bootstrap,Html,Css,Asp.net Mvc,Twitter Bootstrap,我有一个使用jQueryVal的MVC表单(带有布局页面_layout.cshtml)。当我以空必填字段提交时,验证消息会正确显示,但没有应用Site.css中的样式(覆盖bootstrap.css)。我怀疑这是因为jQueryVal正在运行客户端。我发现唯一可行的方法是将实际样式放置在_布局页面上 BundleConfig.cs bundles.Add(new StyleBundle("~/Content/css").Include("~/Content/bootstrap.css",

我有一个使用jQueryVal的MVC表单(带有布局页面_layout.cshtml)。当我以空必填字段提交时,验证消息会正确显示,但没有应用Site.css中的样式(覆盖bootstrap.css)。我怀疑这是因为jQueryVal正在运行客户端。我发现唯一可行的方法是将实际样式放置在_布局页面上

BundleConfig.cs
    bundles.Add(new StyleBundle("~/Content/css").Include("~/Content/bootstrap.css","~/Content/Site.css"));
Site.css

.field-validation-error {
    color: red;
    font-weight: bold;
}
_Layout.cshtml(此样式块有效,但放置在Site.css中时无效)


@视图包。标题
@style.Render(“~/Content/css”)
@*TODO site.css未覆盖验证错误文本颜色*@
.字段验证错误{
颜色:红色;
字体大小:粗体;
}
渲染标记

在layout.cshtml中您已经使用过!重要,但在site.css中没有-您是否尝试在site.css中使用它?如果是,您是否尝试过级联css,例如

body .field-validation-error {
    color: red !important;
    font-weight: bold !important;
}

我在IE中尝试了这个页面,红色验证错误的样式运行良好。显然,在Chrome中,带有.cshtml utf-8元数据头的.css文件也应该是utf-8。谁知道??我用记事本++打开了一个新文档,确保它是utf-8,粘贴了我的.css内容,保存了它,覆盖了现有的.css,就像魔术一样!它起作用了!:)

我试过两种方法。它仍然不会呈现红色。
body .field-validation-error {
    color: red !important;
    font-weight: bold !important;
}