简体   繁体   中英

Responsive Design with @media in CSS

I tried to make my website responsive but it does not work. With @media i want to define different areas but with my code nothing chances.

    @media (max-width: 1400px) {
    #football {
        left: 70%;
        top: 0%;
    }
    
    #skiing {
        left: 70%;
        top: 30%;
    }
    
    #volleyball {
        left: 70%;
        top: 60%;
    }
    
}

Is there something wrong?

Make sure you have the meta tag embedded inside <head> :

html:

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

css:

@media all and (max-width: 1400px){

/* your code */

}

try to define the type

@media all and (max-width: 1400px){
     your code
}

and make sure to add the meta tag in the head tag

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

Make sure to put the media query at the end of your code. Also don't forget to add this meta tag to the head element in html file.

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

By the way try editing query like this:

@media only screen and (max-width: 1400px) {
    #football {
        left: 70%;
        top: 0%;
    }
    
    #skiing {
        left: 70%;
        top: 30%;
    }
    
    #volleyball {
        left: 70%;
        top: 60%;
    }
    
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM