C# MVC使用CSHTML href
我的系统中有这个cshtml局部布局视图C# MVC使用CSHTML href,c#,css,asp.net-mvc,razor,C#,Css,Asp.net Mvc,Razor,我的系统中有这个cshtml局部布局视图 <div class="row" style="background: #816BFA; margin-left: 0; margin-right: 0; margin-top: 30px; height: 7%"> <h class="col-sm-4" style="text-align: center; font-size: 18px; color: black; height: 40px; top: 8px">&l
<div class="row" style="background: #816BFA; margin-left: 0; margin-right: 0; margin-top: 30px; height: 7%">
<h class="col-sm-4" style="text-align: center; font-size: 18px; color: black; height: 40px; top: 8px"><i class="glyphicon glyphicon-home"></i>@Html.ActionLink("Truck List","TruckList")// this</h>
<a href="index.html" class="col-sm-4" style="text-align: center; font-size: 18px; color: black; height: 40px; top: 8px"><i class="glyphicon glyphicon-book"></i> Reports</a>
<a href="index.html" class="col-sm-4" style="text-align: center; font-size: 18px; color: black; height: 40px; top: 8px"><i class="glyphicon glyphicon-user"></i> User Accounts</a>
</div>
@ActionLink(“卡车列表”、“卡车列表”)//这个
输出是这样的
您可能看不到文本
“卡车列表”
,因为在html.action链接中,如果单击,它总是变为蓝色。有没有办法像菜单中的其他文本一样将其变黑?此链接重定向到操作“Trucklist”控制器“Trucks”只需添加此CSS类:
h a {
color: black;
}
替换以下代码:
@Html.ActionLink("Truck List","TruckList")
为此:
Html.ActionLink(
"Truck List",
"Create",
CONTROLLERNAME,
null,
new { @style= "color: black;" }
)
只需使用css设置
元素的样式-a:hover{color:?;}
和a:visitored{color:?;}
等(并使用css替换当前那些糟糕的内联样式)我这样做了,但当我打开时,单击链接,它将重定向到/Trucks/AddTruckJobOrder/trucklist它将如何重定向到Trucks/trucklistonly@JohnPaulCirilos-尝试在ActionLink中指定控制器名称。