和
<...
问:如何在剃刀@if {}块中添加间距/边距?
@if (User.IsInRole("Admin"))
{
@* I need to add certain bottom margin here *@
}
else
{
@* I need to add certain bottom margin here *@
}
@* More stuff down here ... *@
答案 0 :(得分:1)
@{
var margin = string.Empty;
if (condition1)
{
margin = "10px";;
}
else if (condition2)
{
margin = "20px";
}
}
<div style="margin-bottom: @margin">
my stuff
</div>
这是实现这一目标的众多方法之一