Home ASP.NET MVC razor: conditional attribute in CSS block
Reply: 0

ASP.NET MVC razor: conditional attribute in CSS block

user5520
1#
user5520 Published in September 19, 2018, 6:43 pm

Can I use if condition in style tag like this?

<style>
    @@media (min-width: 765px) {
    html,body 
       {
        min-width: auto;
        width: 100%;
        @{
            if (ViewBag.type == "pic")
            {
                @:min-height:100vh;
                @:height:auto;
            }
            else {
                @:height: 100vh;
            }
          }
       }
    }
</style>

Or I should use CSS directly in HTML?

share|improve this question
  • why you want condition in css you can try to apply on html tags stackoverflow.com/questions/11785166/… – Saineshwar Nov 15 '17 at 3:18
  • This CSS is for mobile device.Maybe I should write in difference file then dynamic load it. – Yich Lin Nov 15 '17 at 3:24

1 Answer 1

active oldest votes
up vote 2 down vote accepted
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.421851 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO