在我的 cshtml 文件中,我有以下模型指令
@model Model.Common.CameraPopupModel
如何将 Model.CustomHeight 设置为 css 中的 max-height 属性
<style>
.customBootboxWidth {
width: 1300px;
}
.restrictBodyHeight {
max-height: 420px; /*set Model.Height here instead of hardcoding */
overflow-y: auto;
}
</style>
实现此目标的最佳做法是什么?
最佳答案
像这样,假设 style
在 View 中:
<style>
.customBootboxWidth {
width: 1300px;
}
.restrictBodyHeight {
max-height: @(Model.CustomHeight)px;
overflow-y: auto;
}
</style>
关于css - 从 MVC 模型以编程方式设置 css 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28040676/