Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/283.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# 在ASP.Net MVC3中使用时,按钮中未呈现样式_C#_Css_Asp.net Mvc 3_Razor_Stylesheet - Fatal编程技术网

C# 在ASP.Net MVC3中使用时,按钮中未呈现样式

C# 在ASP.Net MVC3中使用时,按钮中未呈现样式,c#,css,asp.net-mvc-3,razor,stylesheet,C#,Css,Asp.net Mvc 3,Razor,Stylesheet,在我的项目中,按钮单击操作没有按照提供的样式进行渲染,因此我尝试了两种方法,并且都附带了屏幕截图 1.<button type="submit" class = "btn btn-success">@Html.ActionLink("Save", "EmployeeRegistration", "Home")</button> 2.<button type="submit" >@Html.ActionLink("Save", "EmployeeRegistr

在我的项目中,按钮单击操作没有按照提供的样式进行渲染,因此我尝试了两种方法,并且都附带了屏幕截图

1.<button type="submit" class = "btn btn-success">@Html.ActionLink("Save", "EmployeeRegistration",
"Home")</button> 
2.<button type="submit" >@Html.ActionLink("Save", "EmployeeRegistration", "Home",new{@class = "btn
     btn-success"})</button>
1@Html.ActionLink(“保存”、“员工注册”,
“家”)
2.@Html.ActionLink(“保存”、“雇员注册”、“主页”,新的{@class=“btn
btn成功“})
两者都有风格问题


试一下,看看下一行给你的是什么输出:-

<input type="submit" class = "btn btn-success" value="Save" />
您在按钮内使用超链接,这就是您的按钮未对齐的原因

使用此样式:-

.btn {
display: inline-block;
padding: 6px 12px;
margin-bottom: 0;
font-size: 14px;
font-weight: normal;
line-height: 1.428571429;
text-align: center;
white-space: nowrap;
vertical-align: middle;
cursor: pointer;
border: 1px solid transparent;
border-radius: 4px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
-o-user-select: none;
user-select: none;
}
试试这个

@Html.ActionLink("Save", "EmployeeRegistration", "Home", new{ }, new{@class = "btn
     btn-success"})

你在使用引导程序吗?当我使用上面的代码时,它工作正常,但是按钮文本不可见,这意味着它没有按照样式进行渲染。这就是问题。在样式表中添加CSS类。它已经存在了…所有CSS样式都加载到布局页面中,这意味着你的样式正在相互覆盖。您可以通过inspect元素找到它。一些
a
样式正在覆盖您的
.btn
类。这个很好用。使用(Html.BeginForm(“EmployeeRegistration”,“Home”,FormMethod.Post))更新了操作名和控制器名,如下…@
@Html.ActionLink("Save", "EmployeeRegistration", "Home", new{ }, new{@class = "btn
     btn-success"})