BlazorStyled icon indicating copy to clipboard operation
BlazorStyled copied to clipboard

Media Queries not working after upgrade to v3

Open esso23 opened this issue 5 years ago • 4 comments

Example class:

<Styled @bind-Classname="@ExtraSmallOnlyClass">
    @@media (min-width:0px) and (max-width:599.95px) {
    display: none;
    }
</Styled>

When I inspect it in Chrome the styled div looks like this <div class=" "> ... (There's space instead of class)

esso23 avatar Jun 16 '20 16:06 esso23

I will check it out right away, sorry about that

chanan avatar Jun 16 '20 16:06 chanan

@esso23 Did that syntax work prior to V3? If so, I will need to work on getting it back up and running again. In the meantime you can use the following syntax:

<Styled @bind-Classname="@ExtraSmallOnlyClass">
        @@media (min-width:0px) and (max-width:599.95px) {
            &{
                display: none;
            }
        }
    </Styled>

The & will be replaced by the dynamic name of the class

chanan avatar Jun 16 '20 16:06 chanan

Yes, it worked with 2.2.0. Thanks, I'll use this in the meantime.

esso23 avatar Jun 16 '20 16:06 esso23

It still does not work. This is the class I'm currently trying this on:

<BlazorStyled.Styled @bind-Classname="@FontClass">
    @@media screen and (max-width: 400px) {
        &{
            font-size: 60% !important;
        }
    }

    @@media screen and (min-width: 400px) and (max-width: 600px) {
        &{
            font-size: 70% !important;
        }
    }

    @@media screen and (min-width: 600px) and (max-width: 800px) {
        &{
            font-size: 80% !important;
        }
    }

    @@media screen and (min-width: 800px) and (max-width: 1100px) {
        &{
            font-size: 90% !important;
        }
    }

    @@media screen and (min-width: 1100px) {
        &{
            font-size: 90% !important;
        }
    }
</BlazorStyled.Styled>

esso23 avatar Jun 17 '20 11:06 esso23