Problem with @media query

1

I'm having a serious problem with Media Query, I'm testing this code and it does not change the state at all, I reduce the screen to the maximum and the colors remain unchanged; HELP

 .box{
  width: 200px;
  height: 200px;
  background-color: red;
}
.box2{
  width: 250px;
  height: 250px;
  background-color: blue;
}
.box3{
  width: 150px;
  height: 150px;
  background-color: pink;
}
@media screen (min-width:480px){
  .box{
    width: 200px;
    height: 200px;
    background-color: black;
  }
  .box2{
    width: 250px;
    height: 250px;
    background-color: green;
  }
  .box3{
    width: 150px;
    height: 150px;
    background-color: grey;
  }
}
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Teste</title>
  <link rel="stylesheet" href="css/main.css" media="screen" title="no title" charset="utf-8">
</head>
<body>
  <header>
  <div>
  <div class="box"></div>
  <div class="box2"></div>
  <div class="box3"></div>
</div>
</header>
</body>
</html>
    
asked by anonymous 29.06.2016 / 06:57

2 answers

2

Change this line @media screen (min-width:480px){ to:

@media screen and (min-width:480px){

EXAMPLE in jsfiddle

Please note that styles that are defined within this media querie are applied when the window is larger than 480px. If you want them to happen when the window size is less than 480px:

@media screen and (max-width:480px){

EXAMPLE in jsfiddle

    
29.06.2016 / 09:22
1

You need to declare the viewport in the head of the html:

<meta name="viewport" content="width=device-width, initial-scale=1.0">

From there on, you can define the average queries in the css normally.

And remembering that it is necessary to put "and" after screen, as in the answer above

@media screen and (min-width:480px)

More about viewport on w3cSchools

    
29.06.2016 / 17:00