簡體   English   中英

通過MVC模型以編程方式設置CSS值

[英]Set css values programmatically from MVC's model

在我的cshtml文件中,我具有以下模型指令

@model Model.Common.CameraPopupModel

如何在CSS中將Model.CustomHeight設置為max-height屬性

<style>
    .customBootboxWidth {
        width: 1300px;
    }
     .restrictBodyHeight {
         max-height: 420px; /*set Model.Height here instead of hardcoding */
         overflow-y: auto;            
     }
</style>

實現此目標的最佳做法是什么?

這樣,假設style在視圖中:

<style>
    .customBootboxWidth {
        width: 1300px;
    }
    .restrictBodyHeight {
        max-height: @(Model.CustomHeight)px;
        overflow-y: auto;            
    }
</style>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM