Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/39.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# 覆盖_Layout.cshtml中的宽度_C#_Css_.net_Model View Controller_Shared - Fatal编程技术网

C# 覆盖_Layout.cshtml中的宽度

C# 覆盖_Layout.cshtml中的宽度,c#,css,.net,model-view-controller,shared,C#,Css,.net,Model View Controller,Shared,在共享布局中,我在body container div上指定了一个宽度 有没有办法在我的一个视图中覆盖这个宽度? 我想继续使用共享布局的其余部分 谢谢。您可以使用ViewBag中传递的参数指定宽度。如果参数不存在,请使用默认值 在_Layout.cshtml中: @{ var layoutWidth = ViewBag.LayoutWidth ?? "640px" /* default value */; } <div id="body-container" style="width:

在共享布局中,我在body container div上指定了一个宽度

有没有办法在我的一个视图中覆盖这个宽度? 我想继续使用共享布局的其余部分


谢谢。

您可以使用ViewBag中传递的参数指定宽度。如果参数不存在,请使用默认值

在_Layout.cshtml中:

@{ var layoutWidth = ViewBag.LayoutWidth ?? "640px" /* default value */;  }
<div id="body-container" style="width: @layoutWidth;"> ... </div>

可以使用在ViewBag中传递的参数指定宽度。如果参数不存在,请使用默认值

在_Layout.cshtml中:

@{ var layoutWidth = ViewBag.LayoutWidth ?? "640px" /* default value */;  }
<div id="body-container" style="width: @layoutWidth;"> ... </div>
有3种解决方案:

1) 在每个视图中放置车身容器

2) 内部视图
车身容器{宽度:1000px!重要}

3) 使用javascript覆盖css。

有3种解决方案:

1) 在每个视图中放置车身容器

2) 内部视图
车身容器{宽度:1000px!重要}

3) 使用javascript覆盖css