Dreamweaver | Mobile Web Design


Mobile Web Design

CSS is the standard in Web and iPhone development.

These days, the typical Web user may not be using a desktop or even a laptop computer but rather a smartphone or tablet.

If you create an alternate style sheet for each device, your design will morph from screen to screen. Along with your standard CSS file for desktop computers, you'll need a phone.css file and a tablet.css file.

In addition, you can use alternate style sheets for print and HTML email. The Web has many facets, and CSS is very adaptable.

CC Users: Click here to read Lecture Six's tipsheet for Dreamweaver CC users.

In this lecture, you can expect to:

Write media queries for mobile phones and tablets.
Restructure page layouts on different devices.
Create alternate style sheets for print.
Learn how to format HTML emails.
Customize your Dreamweaver workspace.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

One column layouts are easier to view on smart phones.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Navigation buttons should be at least 40 pixels wide to allow enough space for the user's finger to touch on.

 

 

CSS3 Media Queries

 

CSS3 media queries detect the width of the user's device, then serve up a phone.css or tablet.css style sheet accordingly. This involves just a few lines of code.

Download the mobile folder from the course downloads area. Unzip it and move it into your dw2projects folder. Open the index.html file.

 
 

To learn how to create media queries, choose your Dreamweaver version below:

 
 

Mobile Phone Style Sheets

The BAlocal home page displays correctly on an iPhone, but there are some obvious layout problems. The container div is 890 pixels wide in a normal Web browser, but here, it is scaled to just 320 pixels wide. This makes the text too small to read. Also, the tiny links in the top nav bar are hard to click. It is possible to browse this site on a mobile device, but it involves a lot of zooming and scrolling.

Optimize Layout

The first order of business is to restructure the layout into a single column. This means getting rid of the polaroid photos in the right sidebar. You could move the polaroids down to the bottom of the page, but since the polaroids are not essential, it will be cleaner to remove them.

1. Expand the phone.css file in the CSS Styles panel. Edit the .sidebar1 style. In the Block category, set display to "none".

You won't see any changes yet, since Dreamweaver is displaying the regular balocal.css styles. Here's how to preview the phone.css file:

 

 

 

Dreamweaver CS6 users: Click the Multiscreen icon in the Document toolbar and choose "320 x 480 Smart Phone".

Windows users: If your work area is maximized, the Window resize options may be grayed out. Make the work area window smaller to activate these options.

Dreamweaver CS5.5 users: Choose "320 x 480 Smart Phone" from the Window Size menu in the bottom-right corner of the Document window.

Windows users: If your work area is maximized, the Window resize options may be grayed out. Make the work area window smaller to activate these options.

Dreamweaver CS5 users: Choose "Edit Sizes" from the Window Size menu.

Windows users: If your work area is maximized, the Window resize options may be grayed out. Make the work area window smaller to activate these options.

Enter a new window size and description,

Click OK. Return to the Window Size menu and choose the new smart phone option.

 
 

Changing the window size triggers the phone.css file. If you scroll over to the right, you'll notice that the polaroids no longer display in the phone view.

A word of warning: Dreamweaver's Smart Phone preview occasionally locks up. If your screen freezes and won't let you select anything, go to File > Save, close your HTML file, then open it again.

2. The next step is to resize the layout to fit a 320 pixel screen. Edit the .container style (in the phone.css), and set the width to 310px.

3. Edit the article style (in the phone.css), and change the width to 310px.

4. Next, edit the body style (in the phone.css). Change the margins to 5px.

The container div is 310 pixels wide, with 5 pixels of body margin on each side. This adds up to 320 pixels, fitting the 320 x 480 media size.

Optimize Images

Let's insert a smaller version of the logo for mobile devices.

1. Select the logo (be careful to select the logo itself, and not the entire container div—you might need to click the logo, pause, and click again), then press your Left arrow key. You'll see your cursor blinking to the left of the logo.

2. Go to Insert > Image, and browse to insert phone-logo.gif from the images folder in the mobile directory.

Switch to Code View and toggle to the Source Code. Both logos should be nested inside an <a href> tag, which links to the homepage.

3. Insert your cursor inside the phone-logo.gif image tag, and type class="phone".

4. Insert your cursor inside the logo.gif image tag, and type class="screen".

5. Toggle to phone.css, and add this class selector:

6. Toggle to balocal.css, and add this class selector:

This may seem crisscrossed, but there is an underlying logic.

In the source code, the small phone-logo.gif is identified with a class of "phone", while the full-sized logo.gif is identified with a class of "screen".

When the page loads, the CSS3 media query identifies the width of the device and serves up the the corresponding style sheet.

Small screens are formatted with the phone.css file. According to the phone style sheet, any element with a class of "screen" is set to display "none". Presto, this hides the full-sized logo in the phone version.

Large screens are formatted with the balocal.css file. And, accordingly, any element with a class of "phone" is hidden from view. This removes the small logo from the normal desktop version.

Use the Multiscreen menu (or the Window Size menu in Dreamweaver CS5) to toggle between the Full Size and Smart Phone views of the BAlocal homepage. You should see the large logo in the Desktop version, and the small logo in the Smart Phone version. Good so far?

7. Expand the phone.css file. Choose the a#logo img selector, and set the margins to 0.

8. If you see a small yellow anchor to the left of the logo, go to View > Visual Aids > Invisible Elements and unselect this option. The yellow anchor tag won't display in the browser, but it takes up space in Design View.

Optimize Background Images

The large photo of metal flower on the BAlocal homepage is actually a background-image. This makes it very easy to swap using CSS.

1. Edit the .home h1 style (in the phone.css). Browse to select the phone-flower.jpg in the images folder. Set the top padding to 205px.

The photo is applied as a background image to the homepage's h1 heading. The top-padding allows space for the image above the heading.

That's all there is to it; no changes to the source code are necessary. Swapping background images is much easier than swapping regular content images, like the logo. Use CSS background images as much as possible, for all decorative images throughout your site. Insert normal content images for graphics that are integral to the content, like logos, product photos, or any image that should print along with the text.

Optimize Navigation: Option 1

This is looking better, but the top-nav bar is getting cut off. Also, the tiny links are hard to select.

1. Edit the ul.mainnav li (in the phone.css file). In the Block category, delete the display "inline" property. This will transform the list from a horizontal list to a vertical list.

In the Box category, delete the 16px right-padding. Add 15px left-padding.

In the Border category, uncheck "same for all" and add a solid, 1 pixel gray bottom border. Click OK.

2. Edit the ul.mainnav a, ul.mainnav a:visited (in the phone.css file). In the Type category, set the font size to 12px, the line-height to 20px, and text-transform to "uppercase".

In the Block category, add 1 pixel of letter-spacing. Click OK.

The final nav-bar is certainly more usable. The links take up a lot of screenspace, but it is easy enough to scroll down to the content.

If you would like to compress the navigation, take a look at a second option below.

Optimize Navigation: Option 2

1. Copy the following lines of code:

<script src=
"http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js">
</script>
<script type="text/javascript" src="js/pagechanger.js"></script>

Switch to Code View. Toggle to the Source Code and paste into the Document head:

These scripts dynamically create the select menu. The jquery script links to ajax.googleapis.com. The pagechanger.js file is saved locally, inside the js folder in the mobile directory. If you want to use this script in another project, you'll need to copy the js folder into that project's local site folder.

2. Preview in Live View. You'll see both the list menu and the select menu. Let's hide the list menu in the phone version.

Edit the ul.mainnav (in the phone.css file). In the Block category, set display to "none".

Preview again in Live View (the select menu won't appear in Design View). The rest of the pages haven't been created yet, but the select menu does function as a working navigation menu.

3. To finish up, hide the select menu from the Desktop view. Toggle to the balocal.css file, and add the following style:

Final Refinements

Make these final adjustments to the phone.css file:

1. Edit the p tag selector, and set text-align to "left".

2. Edit the h1 tag selector, and set text-align to "left". Change the font-size to 15px.

3. Edit the h1, h2, h3, h4, h5, h6, p selector, and change the right and left padding to 5px.

That does it! A final word of advice: Keep your phone layouts clean and simple. Data transfer rates can be slow, and screenspace is certainly limited.

The desktop version of the ESPN Web site goes for full graphic effect, with gradient background images and large photos.

The screen version of the ESPN Web site.

The mobile version is drastically pared down—small images, no unnecessary graphics—just a clear presentation of the content.

The mobile version of the ESPN Web site as viewed on an iPhone.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Design your print version in black and white to save on printing costs.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Tablet Style Sheets

The average Web layout is 960 pixels wide, but tablets are only 768 pixels. If you would like to adjust the layout for a perfect fit, use an alternate tablet.css file.

 

 

 

Dreamweaver CS6 users: Choose "768 x 1024 Tablet" from the Multiscreen menu.

Dreamweaver CS5.5 users: Choose "768 x 1024 Tablet" from the Window Size menu.

Dreamweaver CS5 users: Choose "Edit Sizes" from the Window Size menu. Create a new window size setting, 890 (width) by 1024 (height).

 
 

Preview the tablet layout in Live View. The problems are evident; the extra logo and list menu are displaying in duplicate, and the polaroids don't fit.

Rather than hiding the polaroids like the phone version, let's rework the tablet layout so both columns fit.

The current desktop layout is 890 pixels wide. The content div has a width of 694 pixels, and the sidebar1 div has a width of 196 pixels.

The container div in the tablet version is 760px wide, and the sidebar1 div is 196px, so the content div should be resized to 564px. (760-196=564).

Display: None Styles

1. You will use the smaller phone version of the logo in the tablet version. So, you just need to hide the larger screen logo.

Toggle to the tablet.css file, and add this class selector:

2. The tablet is wide enough for a full navigation list, so the select menu won't be needed.

Add this class selector to the tablet.css file:

Optimize Layout

Expand the tablet.css file in the CSS Styles panel. We will quickly run through the remaining changes. Be careful to make all edits in the tablet style sheet only.

1. Edit the .container style, change the width to 760px.

2. Edit the .content style, change the width to 564px.

3. Edit the article, change the width to 500px (this will allow 64 pixels of space between the article and sidebar).

4. Edit the body, change the margins to 3px.

Don't worry if the columns don't fit just yet—the nav bar is bumping down the sidebar, but you'll be getting to that shortly.

Optimize Background Images

1. Edit the .home h1 style. In the Background category, browse to select the tablet-flower.jpg. In the Box category, change the top-padding to 338 pixels.

Optimize Navigation

1. Edit the ul.mainnav li. Change padding-right to 12px.

2. Edit ul.mainnav a, ul.mainnav a:visited. Change the font-size to 14px.

Final Refinements

1. Edit the h1 tag selector, and change the font-size to 14px.

2. Edit a#logo img, and add 15 pixels of top-margin.

Fluid Grid Layouts

Dreamweaver CS6's new Fluid Grid Layout tool uses media queries in combination with proportion-based grids to adapt to different screen sizes (aka Responsive Web Design). If you'd like to try this out, take the tutorial below:

 

 

 

Fluid Grid Layouts in Dreamweaver CS6

 
 

Print Style Sheets

Download the print folder from the course downloads area. Unzip it and move it into your dw2projects folder. Open the tours.html file. Preview the page in a browser and do a print preview.

There are some obvious problems here. The logo is meant to be seen against a dark background, and it looks terrible on a white page. The pink text is a waste of colored ink—it would be more cost efficient to print all the content in grayscale. Also, printing the top nav list isn't necessary.

To quickly format this page for printing, start with a standard print.css file.

1. Click the link icon at the bottom of the CSS Styles panel to attach a new external style sheet.

Browse to select the print.css file from the print folder, and choose "print" from the list of media types. Click OK.

The newly attached print.css file will be listed in the Related Files toolbar. However, if you do a print preview, you'll notice that not much has changed. The browser is processing styles from both style sheets—balocal.css and print.css—in order to generate the print settings.

It is necessary to tell the browser to use the balocal.css file for screen media, and the print.css file for print.

2. Switch to Code View. The print.css file is already set to media="print", but you need to add a media tag for balocal.css, media="screen".

Back in Design View, go to View > Toolbars > Style Rendering to display the Style Rendering toolbar. Click the printer icon to preview how the document will look printed.

Display: None

You can used the display "none" property to remove elements from the printed version of the Web page. For example, navigation bars don't usually need to be printed, and neither do advertisements or decorative images.

The row of polaroid photos is purely decorative and a waste of ink and paper to print out.

1. Toggle to the print.css file and look for this grouped selector:

This nav selector hides the navigation bar. The .screen selector hides any element with a class of ".screen".

Add another selector to the list: .polaroid (this will hide the polaroid image, which has a class of ".polaroid"). Don't forget the comma after nav, (grouped selectors are separated by commas).

Toggle back to Design View. The polaroid photos should now be hidden in the printed layout.

2. It would be better to use a black and white BAlocal logo in the printed version of the page. Click your cursor to the right of the pink logo, then insert logo_print.gif from the images folder.

3. Switch to Code View and toggle to view the Source Code. Apply a class of "screen" to the logo.gif, and a class of "print" to the logo_print.gif.

4. Toggle to the balocal.css file. Add this selector to hide the print logo from the screen version of the Web site:

Toggle between the print and screen media views. Make sure the proper logo is displaying in both versions.

Type Styles

In the screen view, the pricing info is styled with a .yellow class selector. We don't want yellow text in the printed version, but the prices could be set in a bolder font-weight.

1. Create a new style. Choose the Class selector type, and name the style .yellow. Define the style in the print.css file. In the Type category, choose "bold" from the font-weight menu.

The heading and paragraph styles in the print.css file include general type formatting as suggested by Stephanie Rewis' article From Screen to Print. Make any further type adjustments, as you see fit.

URLs

Preview the page in a browser and do a print preview. You'll notice something that didn't appear in Dreamweaver's print preview: complete URLs are listed for links to external Web sites.

The URL setting is controlled by the following group of selectors in the print.css file.

The final printed page is much more readable. Nice work!

 

 

 

 

Upload all images to a Web server and use absolute URLs.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Keep the original version of the email file in case you need to edit the design later. The premailer version (with inline styles) will be harder to edit than the original version (with internal styles).

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

HTML Email

HTML email is a great way to drive traffic to your Web site by sending announcements, newsletters, daily features, press releases, and sale alerts.

Designing an HTML email layout requires a different strategy than a typical Web page. You'll need to contend with varying levels of CSS support in different email clients. Layout tables and inline styles deliver the most consistent results. It is a step back from current Web standards, but with a little testing you'll be on solid footing.

Design the Email Layout

Start by planning the page layout. Look through email design galleries for ideas.

 
 

http://www.campaignmonitor.com/gallery/

http://htmlemailgallery.com/

http://inboxaward.com/

 
 

Consider using a free HTML email template to save yourself a lot of time.

Create a new folder for your email project within the site's local site folder.

In Dreamweaver, open a new HTML file with no layout, and save it in the email folder.

Save all the images that you are planning to use in the email within this same folder. Don't use a separate "images" directory. Keeping the email HTML file and images in the same folder will make it easier to write the absolute image paths later on.

Build the table layout, setting all widths in pixels. The overall layout should be about 550 pixels wide.

Insert images into the layout. Use images sparingly: if the email takes too long to open, the user will delete it before the images even load.

Also, prepare yourself for the possibility that the email client might block images all together. The email should still be legible in plain text format. Add alternate text for each image by filling in the Alt field in the Property inspector.

Add CSS formatting, saving all styles as internal styles. Choose (This document only) from the Rule Definition menu in the New CSS Rule dialog.

Save all new styles as internal styles.

Reference a CSS support chart to see which properties are supported.

Change Links to Absolute

The images won't be embedded in the final email. Instead, the images are uploaded to your Web server and accessed via absolute URLs.

Upload the email folder to your Web server. Then, open the email HTML file in a browser and determine the absolute URL for each image. An easy way to do this is to Control-click the image (Right-click in Windows) and choose "View Image" from the context menu. The image will open in a separate window. Copy and paste the URL from the browser's address bar. Remember that absolute URLs start with http://, for example:

http://www.yoursiteurl.com/email/officephoto.jpg

Edit your email HTML file in Dreamweaver. Change each image path to an absolute URL. Links to other HTML files should also be absolute.

Move CSS Inline

Gmail will ignore any internal CSS styles within the document head. The only way around it is to use inline styles.

Inline styles are written in each line of HTML code, like this,

The inline styles are written into each table cell and paragraph tag.

Writing inline styles is a tedious process. You have to repeat the same style info over and over in each paragraph and table cell. Rather than sodding through it yourself, use a free online tool to automate the process.

Switch to Code View, and go to Edit > Select All and Edit > Copy to copy all the source code. Visit the premailer.dialect.ca Web site.

Click "Use HTML as the source", Edit > Paste the source code into the text field, and click the "Do it to it!" button.

Copy and Paste your source code into the Premailer window.

Premailer will process your HTML code, converting internal styles to inline styles and relative links to absolute links (in case you missed any links in the previous step, but remember, you still need to post the images on your Web server).

Click the "View the HTML results" field, Edit > Select All and Edit > Copy.

Read the HTML and CSS warnings to make sure the the potential errors won't affect the legibility of your content.

Back in Dreamweaver, create a new HTML file and save to your email folder. Switch to Code View, go to Edit > Select All to select the document head and body tags, and hit your Delete key. Then, Edit > Paste to paste the code from the Premailer site. Save your final, email-ready code. Connect to your Web server and post the entire email folder online.

Test and Deliver

You're ready to send out the email! But first, do some testing by opening accounts in Hotmail, Gmail, and Yahoo mail and sending the email to yourself to see how it looks. For a more serious analysis, use an email testing service.

The process of sending the actual email will vary depending on your email service. In Apple Mail, it couldn't be easier: you just open the Web page in Safari, then choose File > Mail Contents of this Page. Consult your email program's help documentation for exact instructions.

Your Custom Workspace

By now, you've spent a lot of time in Dreamweaver. You know the panels you use most frequently, and the panels you never use. Let's wrap up this final lecture by creating a custom workspace.

Clean up your current workspace by choosing Designer > Reset Designer from the Workspace menu.

In Dreamweaver CS6, you'll find the Workspace menu on the right side of the Application bar:

Dreamweaver CS6

In Dreamweaver CS5, the Workspace menu is positioned on the left:

Dreamweaver CS5

Consider which panels you want to keep, and which panels you could live without. Here are a few suggestions:

 
 
  • The Adobe Browser Lab panel is docked in the top-right corner of the Dreamweaver interface. To save some screenspace, close the Adobe Browser Lab panel by choosing "Close Tab Group".

    Click the menu button in the upper-right corner of a panel to remove it from the Dreamweaver workspace.


    Adobe BrowserLab can be accessed by Edit > Preview in Browser, so you won't need this side panel.

  • If you aren't using Business Catalyst, then you can close that panel too.

  • Grab the Insert tab and drag it down, so it docks with the Files panel.

    Click and drag to dock a panel in another tab group.


  • If you often use snippets, go to Window > Snippets. Dock it with the Files panel tab group.

  • Go to Window > Results > Search. Click and drag the Property inspector to dock it with the Results panel.

    Docking the Property inspector with the Results panel saves a lot of screenspace.

 
 

When you have arranged your workspace just the way you like it, choose "New Workspace" from the Workspace menu. Name your workspace and you'll be able to access it for many, many future Dreamweaver projects!

   
 
   

Discussion
Share your thoughts and opinions with your fellow students in the Discussion area.

Exercise
Create a Web site using alternate style sheets for phones and tablets.