Mix CSS with ASP c #

0

I would like to know if it is possible to mix C # code with css in a style sheet, at this moment I have this:

 :root {
   --fond_Size: 14px !important; 
   --title_Size: 20px !important; 
   --padding_span: 5% !important; 
   --fond_Size_Popup: 30px !important;  
}

I would like something like this:

:root {
   --fond_Size: @ViewBag.Size + px !important; 
   --title_Size: 20px !important; 
   --padding_span: 5% !important; 
   --fond_Size_Popup: 30px !important;  
}

It should be emphasized that the word px should be concatenated, or something like that ...

    
asked by carlos 04.12.2018 в 02:15
source

1 answer

0

You can not mix CSS and C # code, but you can change the property of an html control with javascrips or at the moment it is rendered.

Depending on the way in which you render the screen, be it by Webform, Razor, Asp, etc., it is the technique that you should use.

I give you an example with Razor:

@if (ViewBag.Size == 0) {               } else {         }

    
answered by 04.12.2018 в 13:14