Introduction to CSS Media Query - Lesson 11

Slides:



Advertisements
Similar presentations
Recognizing the Benefits of Using CSS 1. The Evolution of CSS CSS was developed to standardize display information CSS was slow to be supported by browsers.
Advertisements

Web Pages and Style Sheets Bert Wachsmuth. HTML versus XHTML XHTML is a stricter version of HTML: HTML + stricter rules = XHTML. XHTML Rule violations:
Media Queries Jeffery Davis CIT media is used to define different style rules for different media types and devices. Media queries.
4.01 Cascading Style Sheets
RESPONSIVE DESIGN Sources: Kadlec, T. (2012). Implementing responsive design. Berkeley, California: New Riders Publishing. MarcotteMarcotte, E. (2010).
LEARN THE QUICK AND EASY WAY! VISUAL QUICKSTART GUIDE HTML and CSS 8th Edition Chapter 12: Building Responsive Webpages.
TUTORIAL 8: Enhancing a Web Site with Advanced CSS
CIT 256 Mobile Web Development Dr. Beryl Hoffman.
Lesson 15: Mobile Design and Layout Introduction to Adobe Dreamweaver CS6 Adobe Certified Associate: Web Communication using Adobe Dreamweaver CS6.
WDV 331 Dreamweaver Applications Designing Websites for Mobile Devices Dreamweaver CS6 Chapter 11.
Using Styles and Style Sheets for Design
INTRODUCTION TO HTML5 CSS Styles. Understanding Style Sheets  HTML5 enables you to define many different types of content on a web page, including headings,
CSS Positioning Creating Special Effects with CSS CS202 Working with Cascading Style Sheets (Chapter 4) CS202 1.
 This presentation introduces the following: › 3 types of CSS › CSS syntax › CSS comments › CSS and color › The box model.
Tutorial 8 Enhancing a Web Site with Advanced CSS
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 7 Key Concepts 1 Copyright © Terry Felke-Morris.
HTML, CSS, and XML Tutorial 8 Enhancing a Web Site with Advanced CSS.
WebD Introduction to CSS By Manik Rastogi.
Cascading Style Sheets (CSS) Internal Style Sheets Classes
Working with Cascading Style Sheets
Web Development & Design Foundations with HTML5
CSS Box Model.
The Box Model in CSS Web Design – Sec 4-8
4.01 Cascading Style Sheets
Responsive
Google fonts CSS box model
The Box Model in CSS Web Design – Sec 4-8
A better approach to mobile
Responsive Web Pages.
Concepts for fluid layout
CS1220 Web Programming Saloni Chacha.
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Introduction to Web programming
Box model.
Web Development & Design Foundations with HTML5
The Box Model in CSS Web Design – Sec 4-8
Web Systems & Technologies
CS 0134 (term 2181) Jarrett Billingsley
RESPONSIVE WEB DESIGN.
Objectives Create a media query Work with the browser viewport
Web Development & Design Foundations with HTML5 8th Edition
Web Development & Design Foundations with HTML5 7th Edition
Cascading Style Sheets
CASCADING STYLE SHEET CSS.
Different Screen Size Different Design…
Responsive Design.
Chapter 8 More on Links, Layout, and Mobile Key Concepts
2017, Fall Pusan National University Ki-Joune Li
Responsive Web Design (RWD)
For the World Wide Web Positioning Objects with CSS
CSS Box Model.
Responsive Web Design (RWD)
Anatomy of an App User Interface Design
Responsive Framework.
Web Development & Design Foundations with H T M L 5
Basics of Web Design Chapter 8 More on Links, Layout, and Mobile Key Concepts Copyright © 2014 Terry Ann Morris, Ed.D.
Responsive Web Design (RWD)
WEB DESIGN FOR MULTIPLE SCREENS
Tutorial 4 Creating Special Effects with CSS
Chapter 7 Absolute/relative hyperlinks Frag id 3-column site
CSS and Class Tools.
Web Client Side Technologies Raneem Qaddoura
Web Development & Design Foundations with HTML5
Web Client Side Technologies Raneem Qaddoura
Concepts for fluid layout
4.01 Cascading Style Sheets
CSS Box Model.
CSS Box Model.
17 RESPONSIVE WEB DESIGN.
Christopher Harrison Jeremy Foster
Presentation transcript:

Introduction to CSS Media Query - Lesson 11 Publisher : Attitude Academy

What is Media Query CSS The @media rule, introduced in CSS2, made it possible to define different style rules for different media types. Examples: You could have one set of style rules for computer screens, one for printers, one for handheld devices, one for television-type devices, and so on. Unfortunately these media types never got a lot of support by devices, other than the print media type.

MEDIA QUERY CSS Introduces Media Queries Media queries in CSS3 extend the CSS2 media types idea: Instead of looking for a type of device, they look at the capability of the device. Media queries can be used to check many things, such as: width and height of the viewport width and height of the device orientation (is the tablet/phone in landscape or portrait mode?) resolution Using media queries are a popular technique for delivering a tailored style sheet to tablets, iPhone , and Androids.

MEDIA QUERY Browser Support The numbers in the table specifies the first browser version that fully supports the @media rule. Element <video> 4.0 9.0 3.5 10.5

Media Query Syntax A media query consists of a media type and can contain one or more expressions, which resolve to either true or false. @media not|only mediatype and (expressions) {     CSS-Code; } The result of the query is true if the specified media type 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, following the normal cascading rules. Unless you use the not or only operators, the media type is optional and the all type will be implied. You can also have different stylesheets for different media: <link rel="stylesheet" media="mediatype and|not|only (expressions)" href="print.css">

MEDIA QUERY CSS Media Types Value Description 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

MEDIA QUERY Media Queries Simple One way to use media queries is to have an alternate CSS section right inside your style sheet. The following example changes the background-color to light green if the viewport is 480 pixels wide or wider (if the viewport is less than 480 pixels, the background-color will be pink):

Example Desktop <style> body { background-color: pink; } @media screen and (min-width: 480px) { background-color: lightgreen; </style> </head> <body> <h1>Resize the browser window to see the effect!</h1> <p>The media query will only apply if the media type <br> is screen and the viewport is 480px wide or wider.</p> </body> Mobile Phone

Example <body> <div class="wrapper"> <div id="leftsidebar"> <ul id="menulist"> <li class="menuitem">Menu-item 1</li> <li class="menuitem">Menu-item 2</li> <li class="menuitem">Menu-item 3</li> <li class="menuitem">Menu-item 4</li> <li class="menuitem">Menu-item 5</li> </ul> </div> <div id="main"> <h1>Resize the browser window to see the effect!</h1> <p>This example shows a menu that will float to the left of <br> the page if the viewport is 480 pixels wide or wider. If the viewport<br> is less than 480 pixels, the menu will be on top of the content.</p> </div></div> </body>

<meta name="viewport" content="width=device-width, initial-scale=1 <style> .wrapper {overflow:auto;} #main {margin-left: 4px;} #leftsidebar {float: none;width: auto;} #menulist {margin:0;padding:0;} .menuitem { background:#CDF0F6; border:1px solid #d4d4d4; border-radius:4px; list-style-type:none; margin:4px; padding:2px; } @media screen and (min-width: 480px) { #leftsidebar {width:200px;float:left;} #main {margin-left:216px;} </style> </head>

Desktop Mobile Phone

Visit Us : Attitude Academy