Why is my media tag not working with my styled ocmponent?

51 views Asked by At

I am trying to add a @media to a styled-component. Here is my Component:

const Image = styled.img`
  display: none;
  @media(width >= 600px) {
    display: block;
  };
`;

The @media is never triggered. What am I doing wrong? How do we get @media tags to work with styled-components?

1

There are 1 answers

0
Dario On BEST ANSWER

Your media query is wrong, as you would do for standard CSS you need to specify the min-width like:

@media (min-width: 600px) { 
   display: block;
}