Brad Walls Brad Walls - 5 months ago 19
CSS Question

Applying media query to an element

Trying to apply a media query to one particular div, but nothing is happening.

<style>
@media only screen and (min-device-width : 320px) and (max-device-width : 480px) {
.rating {
margin: auto;
}
</style>

Answer

Seems you already missed a } after .rating

<style>
@media only screen and (min-device-width : 320px) and (max-device-width : 480px) {
.rating {
        margin: auto;
  }
} /* <-- this one you missed */`enter code here`
</style>

Also if its not device you can try to change min-device-width to min-width same for max-width.

also check the device resolution accordingly and don't forgot to add meta tag

Comments