본문 바로가기
Svelte/CSS

MVC - .Net razor how to selection dynamic CSS

by 올엠 2020. 10. 28.
반응형

You can use it in View file as below.
First, use according to the condition

@if (item.service == 0)
{
     <div class="badge alert-danger">
           @Html.DisplayFor(modelItem => item.service) ms
     </div>
}
else
{
      <div class="badge alert-success">
             @Html.DisplayFor(modelItem => item.service) ms
       </div>
}

Here is how to use it through true or false.

<div class="@(item.ping < 1000 ? "badge alert-success" : "badge alert-warning")">@Html.DisplayFor(modelItem => item.ping) ms                    </div>

In this case, css can be applied according to the following condition.

반응형

'Svelte > CSS' 카테고리의 다른 글

CSS - Select 비활성화, 기본값 설정  (0) 2022.05.08
CSS - grid 기본 이해, 2차원 배열하기  (0) 2022.04.26
CSS - element 요소 정리  (0) 2022.04.03
CSS 마침표 "."의 의미  (0) 2022.04.02
Sass(SCSS)란, 사용법  (0) 2022.03.29

태그

, , ,

댓글0