MOTOSHARE 🚗🏍️

Rent Bikes & Cars Directly from Owners

Motoshare connects vehicle owners with people who need bikes and cars on rent. Owners earn from idle vehicles, and renters get flexible ride options.

Visit Motoshare

How to use Media Query in CSS for a responsive webpage?

CSS

A media query consists of an optional media type and zero or more expressions that limit the style sheets’ scope by using media features, such as width, height, and color.

Syntax: –

@media not|only mediatype and (expressions/ media features) {   CSS;  }

Ex: –

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

    body {

        background-color: lightgreen;    }

}

@media (min-width: 480px) {

    body {

        background-color: lightgreen;    }

}

  • all – Used for all media type devices
  • print – Used for printers
  • screen – Used for computer screens, tablets, smart-phones etc.
  • speech – Used for screenreaders that “reads” the page out loud

If you use the not or only operators, you must specify an explicit media type.

And-

  • @media (min-width: 800px) { CSS }
  • @media (min-width: 800px) and (orientation: landscape) { CSS }
  • @media screen and (min-width: 800px) and (orientation: landscape) { CSS }

Or (Comma , )-

  • @media (min-width: 800px), (orientation: landscape) { CSS }

Not-

  • @media not all and (min-width: 800px) { CSS }
  • @media not (all and (min-width: 800px)) { CSS }
  • @media (not all) and (min-width: 800px) { CSS }
  • @media not screen and (color), print and (color) { CSS }
  • @media (not (screen and (color))), print and (color) { CSS }
0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
0
Would love your thoughts, please comment.x
()
x