FOLLOW US ON TWITTER



FOLLOW US



img/blogimg/css3.jpg


@an idea 1042

CSS3 MEDIA-QUERY


2021-11-16 22:04 · 3 min read

What is a CSS3 media query? CSS3 media query is used to create responsive web pages. If we want to create a responsive design for our laptop, tablet, and mobile then we can apply the CSS3 media query rule on our web page.
 

How to use @media-query?

If you have some knowledge of the device width range. Then you can easily create responsive web layouts by using the code given below.

 

<style>
@media screen and (max-width:480px){
property: value;
property: value;
property: value;
}
</style>
  • This code works for the screen width size less than 480px (mobile devices).
  • Click on the try it button and run the code. Minimize your PC screen Zoom In. Use can see the code of the H1 tag change from green to red.

Note: please do not use container width greater than the max-width of a media query and always try to use width percentage(%) unit.

 

<head>
<style>
h1{color:green}
@media screen and (max-width:300px){
h1{color:red}
}
</style>
</head>

<body>
<h1>@media-query</h1>
</body>

 

@media-query min-width?

When we use min-width then the code inside the @media rule is used for the screen width is greater than that min-width value. We can see the example of @media min-width below.

 

<style>
@media screen and (min-width:500px){
property: value;
property: value;
property: value;
}
</style>

 

  • This code works for a screen width size greater than 500px (mobile devices).
  • Click on the try it button and run the code. change your PC's screen size, you can see the changing color of texts.
<head>
<style>
h1{color:green}
@media screen and (min-width:400px)
{
h1{
color:red
}
}
</style>
</head>

<body>
<h1>
@media-query
</h1>
</body>

 

TAGS:






POST COMMENTS
No Comment

Please login to post comment




POPULAR POSTS

best free web hosting services...
what is new in miui 11?...
free website ssl security using cloudfla...
do you want to make money online?...
CSS3 @IMPORT RULES...
What is HTML Anchor Tag and Hyperlinks?...
CSS3 RESPONSIVE UI...
How to host a web page in 10 minutes....
Tables HTML...
CSS3 FUNCTIONS...
How to use CSS3 Overflow Property?...
CSS3 FILTERS...


RECENT COMMENTS

2022-03-05 11:05
By coder on XAMPP - MySQL shutdown unexpectedly | How to fix MySQL crash unexpectedly
2021-10-12 12:34
By abnongoke on do you want to make money online?
2021-10-12 12:34
By abnongoke on how to get a free website domain name?
2021-10-12 12:34
By solar panel for shed on what is new in miui 11?
2021-10-12 12:34
By solar panel for shed on best free web hosting services
2021-10-12 12:34
By amos tanui on free website ssl security using cloudflare


SOCIAL SHARE



FOLLOW US ON TWITTER



FOLLOW US ON FACEBOOK



FOLLOW US







Recent Blogs



Contact Us

Subscribe Our News-Letter



Kashipur, 244713
Uttarakhand, India



© blog.theprodevelopers.com 2024. All Rights Reserved. Powered by Pro Developer