session 8.1. tutorial 8: enhancing a web site with advanced css

19
SESSION 8.1. TUTORIAL 8: Enhancing a Web Site with Advanced CSS

Upload: joseph-little

Post on 24-Dec-2015

220 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: SESSION 8.1. TUTORIAL 8: Enhancing a Web Site with Advanced CSS

SESSION 8.1.

TUTORIAL 8: Enhancing a Web Site with Advanced

CSS

Page 2: SESSION 8.1. TUTORIAL 8: Enhancing a Web Site with Advanced CSS

OBJECTIVES

Designing for the Mobile WebTesting a Mobile DesignConfiguring the ViewportIntroducing Media Queries within HTML DocumentsCreating a Mobile Style SheetIntroducing Media Queries within CSS Files

Designing for Portrait Orientation Designing for Landscape Orientation

Page 3: SESSION 8.1. TUTORIAL 8: Enhancing a Web Site with Advanced CSS

DESIGNING FOR THE MOBILE WEB

Page 4: SESSION 8.1. TUTORIAL 8: Enhancing a Web Site with Advanced CSS

TESTING ON MOBILE DEVICES

Six Free Mobile Devices Emulators for testing your site:

http://www.webdesignerdepot.com/2012/11/6-free-mobile-device-emulators-for-testing-your-site/

Page 5: SESSION 8.1. TUTORIAL 8: Enhancing a Web Site with Advanced CSS

CONFIGURING THE VIEWPORT

Mobile devices can display pages written for the larger screens found on desktop computers.

The contents of a Web page are displayed within a window known as the viewport.

Visual viewportLayout viewport

Page 6: SESSION 8.1. TUTORIAL 8: Enhancing a Web Site with Advanced CSS

CONFIGURING THE VIEWPORT

Page 7: SESSION 8.1. TUTORIAL 8: Enhancing a Web Site with Advanced CSS

PRACTICE: CONFIGURING THE VIEWPORT

1. Open the tmc.htm file. Add the viewport meta tag.

Page 8: SESSION 8.1. TUTORIAL 8: Enhancing a Web Site with Advanced CSS

INTRODUCING MEDIA QUERIES WITHIN THE HTML DOCUMENT

To create a media query for loading a style sheet, add the media attribute

media = “devices and|or (features)”

to the link element, where devices is a list of media devices, and features is a list of display features and their values as found on those devices

Page 9: SESSION 8.1. TUTORIAL 8: Enhancing a Web Site with Advanced CSS

INTRODUCING MEDIA QUERIES WITHIN THE HTML DOCUMENT

To associate a style sheet with screen devices that are less than or equal to a specific width, use the querymedia = “screen and (max-width: value)”where value is the maximum allowable width of the screen’s viewport

To associate a style sheet with screen devices that are greater than or equal to a specific width, use the querymedia = “screen and (min-width: value)”where value is the minimum allowable width of the screen’s viewport.

Page 10: SESSION 8.1. TUTORIAL 8: Enhancing a Web Site with Advanced CSS

INTRODUCING MEDIA QUERIES WITHIN THE HTML DOCUMENT

To associate a style sheet with screen devices that fall within a range of screen widths, use the following query:media = “screen and (min-width: value and max-width: value)”

To associate a style sheet with screen devices in portrait or landscape mode, use the querymedia = “screen and (orientation: type)”where type is either portrait or landscape.

Page 11: SESSION 8.1. TUTORIAL 8: Enhancing a Web Site with Advanced CSS

PRACTICE: MEDIA QUERIES WITHIN HTML

1. Add a link to the tmceffects.css style sheet file, using the style sheet for screen devices that have a minimum width of 501 pixels. Add the same media query for the tmclayout.css style sheet file.

2. Use an Internet Explorer conditional comment for versions of IE before version 9 to link to the tmclayout.css and tmceffects.css style sheet for screen devices.

3. Many patients and visitors visit the TMC website using mobile devices. Create a mobile version for TMC. Open tmcmobile.css from your data file folder in your text editor. Enter your name and the date in the comment section of the file, and then save tmcmobile.css.

4. Create a link to the tmcmobile.css file to be accessed by only screen devices with maximum widths of 500 pixels.

Page 12: SESSION 8.1. TUTORIAL 8: Enhancing a Web Site with Advanced CSS

CREATING A MOBILE STYLE SHEET

Page 13: SESSION 8.1. TUTORIAL 8: Enhancing a Web Site with Advanced CSS

PRACTICE: CREATING A MOBILE STYLE SHEET

1. Within the tmcmobile.css file, add a style rule to hide the nav tag within the header element, the image tag within the header element, the main section, the aside and the footer.

2. Set the background color of the body to (107, 140, 80).

3. For the header element, create a style rule to: Change the background with the image file hospview.jpg placed

in the center-bottom of the background with no tiling Set the width to 100% Set the height to 150 pixels.

Page 14: SESSION 8.1. TUTORIAL 8: Enhancing a Web Site with Advanced CSS

PRACTICE: CREATING A MOBILE STYLE SHEET

4. The navigation list containing links to each of the departments at TMC has the id depts. Create a style rule to set the width of this navigation list to 100%.

5. For the h1 elements within the depts navigation list, create a style rule to: Set the font size to 25 pixels Set the font color to white Set the margin to 15 pixels Center the text of the heading

Page 15: SESSION 8.1. TUTORIAL 8: Enhancing a Web Site with Advanced CSS

INTRODUCING MEDIA QUERIES WITHIN CSS

To apply a media query to a collection of style rules, apply the @media rule@media devices and|or (features) {

styles}

in your style sheet, where styles is those styles applied to the specified devices and features.

To import a style sheet based on a media query, apply the following @import rule:@import url(url) devices and|or (features)

Page 16: SESSION 8.1. TUTORIAL 8: Enhancing a Web Site with Advanced CSS

DESIGNING FOR PORTRAIT ORIENTATION

Page 17: SESSION 8.1. TUTORIAL 8: Enhancing a Web Site with Advanced CSS

DESIGNING FOR LANDSCAPE ORIENTATION

Page 18: SESSION 8.1. TUTORIAL 8: Enhancing a Web Site with Advanced CSS

PRACTICE: MEDIA QUERIES WITHIN CSS

1. The preceding styles will be applied by default to the page in portrait orientation. Create an @media rule for the page in landscape orientation.

2. Add the following style rule for list items of the nav element with the depts id displayed in landscape orientation:

Set the width to 30% Float the list items on the left Set the margins to 5 pixels

3. For portrait orientation, the navigation list containing links to each of the departments at TMC has the id depts. Create a style rule for the navigation links to:

Display the links as blocks and set their width to 100% Set the text color to white and align the text in the center Set the space between lines to 50px

Page 19: SESSION 8.1. TUTORIAL 8: Enhancing a Web Site with Advanced CSS

PRACTICE: MEDIA QUERIES WITHIN CSS

4. Along with the “portrait orientation” styles, create style rule for list items in the depts navigation list to: Display the items as blocks Add the background image file arrow.png to the right-center of the background

with no tiling Set the width to 60% and the height to 50 pixels Add top and bottom margins of 5 pixels, and add left and right margins of auto Add a 1px solid white border and a radius of 10px