简体   繁体   中英

Strikethrough text in div based on conditions

I have to strikeout some text which is div based on condition. if @MemberAddressDetails.Status is 'Bad' I have to strikeout all of the blow <div> text. Can we do this with css class?

  <div>@MemberAddressDetails.JobTitle</div>
  <div>@MemberAddressDetails.CompanyName</div>
  <div>@MemberAddressDetails.Country</div>
  <div>@MemberAddressDetails.AddressLine1</div>

I can insert class name in based on condition. that's why I am asking for div class.

I think you're looking for text-decoration: line-through;

 .line-through { text-decoration: line-through; } 
 <div class="line-through">If you want to strike out text, use line-through.</div> 

Adding more to the answer by @sdcr, you can add conditional html attributes or class like given below in razor.

.line-through {
    text-decoration: line-through;
}

   <div class="@(MemberAddressDetails.Status =="Bad" ? "line-through":"")"></div>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM