@media screen not working properly

Asked

Viewed 83 times

3

I’m studying css and html still, so I may be making some banal mistake, I’m not able to solve alone. The problem is the following I set on @media screen a minimum width for it to change the img logo.

Code with original size logo :

.logo {
    width: 56px;
    height: 56px;
    float: left;
    background: url('../img/logo-mobile.png') center center/56px no-repeat;
    font-size: 0;
}

With @media screen

@media screen and (min-height: 480px){
    .logo {
        width: 214px;
        background: url('../img/logo.png') center center/214px no-repeat;
        font-size: 0;
    }

    .btn {
        font-size: 2em;
    }
}

@media even changes the logo, but with a minimum width less than 480px it should go back to the original, only this does not happen.

Where am I going wrong ?

  • See if my answer helps, if the case could validate it, if not comment that we adjusted.

2 answers

3


You didn’t set the width, you set the height, notice:

min-height: 480px

replace with:

min-width: 480px

that will spin perfectly.

@media screen and (min-width: 480px){
.logo {
    width: 214px;
    background: url('../img/logo.png') center center/214px no-repeat;
    font-size: 0;
}}
  • yes hahaha, after posting I saw it.

  • In this case between 480px and 1800px the correct rule will be applied?

  • If the width is less than 480 will show his mobile logo, if bigger, will show the other logo, no matter the size ( as long as it is greater than 480 ). If he wants to put another logo for a much higher resolution just create another @media screen. But this way it will show the normal logo for any resolution that is greater than 480 and will show the mobile logo for any resolution that is less than 480.

  • That’s what I thought, I usually make the biggest pro smallest, so I use max-width.

1

In case you can use (max-width) that is to say maximum width, and when it reaches that width it will make the Pape of it.

  • vlws worked out, thank you ^^

Browser other questions tagged

You are not signed in. Login or sign up in order to post.