{"id":39409,"date":"2015-01-24T05:12:31","date_gmt":"2015-01-24T10:12:31","guid":{"rendered":"http:\/\/www.templatemonster.com\/help\/?p=39409"},"modified":"2016-11-11T04:00:27","modified_gmt":"2016-11-11T09:00:27","slug":"introduction-css-media-queries","status":"publish","type":"post","link":"https:\/\/www.templatemonster.com\/help\/introduction-css-media-queries.html","title":{"rendered":"Introduction to CSS Media Queries"},"content":{"rendered":"<p>This tutorial presents a brief overview of CSS Media Queries.<\/p>\r\n\r\n<p class=\"info-box\"> Media Queries is a CSS3 module allowing content rendering to adapt to conditions such as screen resolution (e.g. smartphone screen vs. computer screen). A media query consists of a media type and one or more expressions, involving media features, which resolve to either true or false. The result of the query is true if the media type specified in the media query matches the type of device the document is being displayed on and all expressions in the media query are true. When a media query is true, the corresponding style sheet or style rules are applied.<\/p>\r\n\r\n  <p>In this tutorial we will cover the following media queries: <strong>Max Width<\/strong>, <strong>Min Width<\/strong>, and <strong>Multiple Media Queries<\/strong>. Specifically, we will see how those queries can be applied to media type <strong>screen<\/strong>.<\/p>\r\n<ol>\r\n<li>\r\n  <p><strong>Max Width<\/strong>. The following CSS will apply if the viewing area is smaller than 550px:<\/p>\r\n  <pre class=\"brush:css\">@media screen and (max-width: 550px) {\r\n  .class {background: #FF0000;}\r\n}<\/pre>\r\n  <p>Please check a live example on the screenshot below:<\/p>\r\n  \r\n<a href=\"\/help\/wp-content\/uploads\/2014\/10\/Introduction-to-CSS-Media-Queries-1.jpg\"><img loading=\"lazy\" src=\"\/help\/wp-content\/uploads\/2014\/10\/Introduction-to-CSS-Media-Queries-1-300x171.jpg\" alt=\"Introduction to CSS Media Queries-1\" width=\"300\" height=\"171\" class=\"aligncenter size-medium wp-image-39410\" srcset=\"https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2014\/10\/Introduction-to-CSS-Media-Queries-1-300x171.jpg 300w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2014\/10\/Introduction-to-CSS-Media-Queries-1-150x85.jpg 150w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2014\/10\/Introduction-to-CSS-Media-Queries-1-1024x584.jpg 1024w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2014\/10\/Introduction-to-CSS-Media-Queries-1.jpg 1063w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a>\r\n<\/li>\r\n<li>\r\n<p><strong>Min Width<\/strong>. The following CSS will apply if the viewing area is greater than 1200px.<\/p>\r\n<pre class=\"brush:css\">@media screen and (min-width: 1200px) {\r\n.class {background: #6666FF;}\r\n}<\/pre>\r\n <p>Please check a live example on the screenshot below:<\/p>\r\n \r\n<a href=\"\/help\/wp-content\/uploads\/2014\/10\/Introduction-to-CSS-Media-Queries-2.jpg\"><img loading=\"lazy\" src=\"\/help\/wp-content\/uploads\/2014\/10\/Introduction-to-CSS-Media-Queries-2-300x138.jpg\" alt=\"Introduction to CSS Media Queries-2\" width=\"300\" height=\"138\" class=\"aligncenter size-medium wp-image-39411\" srcset=\"https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2014\/10\/Introduction-to-CSS-Media-Queries-2-300x138.jpg 300w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2014\/10\/Introduction-to-CSS-Media-Queries-2-150x69.jpg 150w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2014\/10\/Introduction-to-CSS-Media-Queries-2-1024x472.jpg 1024w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2014\/10\/Introduction-to-CSS-Media-Queries-2.jpg 1306w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a>\r\n\r\n<\/li>\r\n<li>\r\n<p><strong>Multiple Media Queries<\/strong>. You can combine  media queries. The following code will apply if the viewing area is between 1050px and 1100px.<\/p>\r\n<pre class=\"brush:css\">@media screen and (min-width: 1050px) and (max-width: 1100px) {\r\n.class {background: #00FF99;}\r\n}<\/pre>\r\n <p>Please check a live example on the screenshot below:<\/p>\r\n \r\n<a href=\"\/help\/wp-content\/uploads\/2014\/10\/Introduction-to-CSS-Media-Queries-3.jpg\"><img loading=\"lazy\" src=\"\/help\/wp-content\/uploads\/2014\/10\/Introduction-to-CSS-Media-Queries-3-300x173.jpg\" alt=\"Introduction to CSS Media Queries-3\" width=\"300\" height=\"173\" class=\"aligncenter size-medium wp-image-39412\" srcset=\"https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2014\/10\/Introduction-to-CSS-Media-Queries-3-300x173.jpg 300w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2014\/10\/Introduction-to-CSS-Media-Queries-3-150x86.jpg 150w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2014\/10\/Introduction-to-CSS-Media-Queries-3-1024x591.jpg 1024w, https:\/\/www.templatemonster.com\/help\/wp-content\/uploads\/2014\/10\/Introduction-to-CSS-Media-Queries-3.jpg 1150w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a>\r\n\r\n<\/li>\r\n<li>\r\n<p>In this tutorial you have found out how to use Media queries.<\/p><\/li>\r\n<\/ol>\r\n\r\n<p>We would recommend you to view our <a href=\"https:\/\/www.templatemonster.com\/admin-templates.php\" title=\"Bootstrap Admin Themes\" target=\"_blank\">Bootstrap Admin Themes<\/a> and find out more about CSS functionality.<\/p>","protected":false},"excerpt":{"rendered":"<p>This tutorial presents a brief overview of CSS Media Queries.<\/p>\n","protected":false},"author":39,"featured_media":43164,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[256],"tags":[514,803,1849,1179],"_links":{"self":[{"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/posts\/39409"}],"collection":[{"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/users\/39"}],"replies":[{"embeddable":true,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/comments?post=39409"}],"version-history":[{"count":0,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/posts\/39409\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/media\/43164"}],"wp:attachment":[{"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/media?parent=39409"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/categories?post=39409"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/tags?post=39409"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}