Table of Contents for
Graphics and Multimedia for the Web with Adobe Creative Cloud: Navigating the Adobe Software Landscape

Version ebook / Retour

Cover image for bash Cookbook, 2nd Edition Graphics and Multimedia for the Web with Adobe Creative Cloud: Navigating the Adobe Software Landscape by Jennifer Harder Published by Apress, 2018
  1. Navigation
  2. Cover
  3. Front Matter
  4. Part I. Welcome to the Adobe Creative Cloud. Where Should You Begin?
  5. 1. Entering the Software Maze or Labyrinth
  6. Part II. Working with Photoshop to Create Web Graphics and Animations
  7. 2. Getting Started
  8. 3. Color Choices: CMYK, RGB, Grayscale, and Index
  9. 4. Saving or Exporting Your Files for the Web
  10. 5. Actions to Speed up File Conversion and Slicing Tools
  11. 6. Tools for Animation
  12. 7. Tools for Video
  13. 8. Other Miscellaneous Items in Photoshop That You Can Use for Web Design
  14. 9. Putting It into Practice with Photoshop CC
  15. Part III. Working with Illustrator to Create Web Graphics
  16. 10. Getting Started with Illustrator CC
  17. 11. Color Choices: CMYK, RGB, and Grayscale
  18. 12. Saving or Exporting Your Files for the Web
  19. 13. Actions to Speed up File Conversion and Slicing Tools
  20. 14. Tools for Animation and Video
  21. 15. Other Miscellaneous Items in Illustrator That You Can Use for Web Design
  22. 16. Putting It into Practice with Illustrator CC
  23. Part IV. Working with Animate to Create Animations, Movies, and HTML5 Canvas
  24. 17. Getting Started with Animate CC
  25. 18. Color Choices: RGB
  26. 19. Importing Your Artwork
  27. 20. Import Your Audio and Video
  28. 21. Working with the Timeline Panel
  29. 22. Exporting Your Files to the Web
  30. 23. Other Miscellaneous Items in Animate that You Can Use for Web Design
  31. 24. Putting It into Practice with Animate CC
  32. Part V. Working with Media Encoder to Create Audio and Video Files
  33. 25. Getting Started with Media Encoder
  34. 26. Working with Your RAW Video Files (AVI and MOV)
  35. 27. Working with Your RAW Video Files and Converting Them to Audio
  36. 28. Working with Your RAW Video Files and Converting Them to an Image Sequence
  37. 29. Putting It into Practice with Media Encoder CC
  38. Part VI. Working with Dreamweaver: Adding Images, Animations, and Multimedia to HTML5 Pages
  39. 30. Getting Started with Dreamweaver CC
  40. 31. Working with Images and Tags
  41. 32. Working with CSS
  42. 33. Working with Images for Mobile Web Design
  43. 34. What Is JavaScript?
  44. 35. Working with Bootstrap, Templates, Library Items, and the Assets Panel
  45. 36. Working with Video, Audio, and Animations
  46. 37. Additional Options to Apply Images in Dreamweaver
  47. 38. Final Testing, Getting Ready to Upload Your Site
  48. 39. Putting It into Practice with Dreamweaver CC
  49. Part VII. Further Dreamweaver Integration with Other Adobe Products for Websites
  50. 40. What Other Programs That Are Part of Adobe Creative Cloud Can I Use to Display My Graphics or Multimedia Online?
  51. Back Matter
© Jennifer Harder 2018
Jennifer HarderGraphics and Multimedia for the Web with Adobe Creative Cloudhttps://doi.org/10.1007/978-1-4842-3823-3_33

33. Working with Images for Mobile Web Design

Jennifer Harder1 
(1)
Delta, BC, Canada
 

In this chapter, you look at how to work with CSS that allows you to make your site more mobile and allows pages to float or stretch on the page, depending on what device you are viewing your website on.

Note

This chapter does not have any actual projects; however, you can use the files in the Part 6 folder to practice opening and viewing for this lesson. They are at https://github.com/Apress/graphics-multimedia-web-adobe-creative-cloud .

This last section on working with images <img> or the background images in CSS concerns how to work with images that may be viewed in other browser devices, like a tablet or smartphone, or even printed by the viewer. CSS and CSS3 have a variety of options that you can use to improve your layout for these situations. In Chapter 35, you look at using a library called Bootstrap, a front-end framework that is free and open source, which allows you to easily construct a mobile site and uses much of the CSS that has been discussed so far in Part 6.

CSS Floats

Sometimes you want images or a group of images to appear to float over the top of the text. This could be when you click over an image and you want to see it as a larger size (also called a light box or modal image ). Or maybe a menu bar that has thumbnails with links that float along the side as you scroll down the page. There are many combinations that you can create; some of the more advanced ones may use JavaScript or jQuery along with the CSS and HTML to accomplish this. You look at JavaScript in Chapter 34; for now let’s see how CSS can help with a float.

The float is a property that specifies an element’s placement alongside its container; it allows text and inline elements to wrap around it.

Like Photoshop CC and its layers, for a <div> or semantic element to float, it needs to be above the other <div> elements.

You can move an element like a div that has a class applied to around using margin-left:auto; and margin-right:auto; to center.
.some-class{
margin-left: auto;
marging-right:auto;
}
Or use the CSS float to move it left, right, or none.
.some-class{
float:left;
}

But none of these properties moves the element above the other elements.

The only way to do this is to use the position in conjunction with properties: top, left, bottom, right, and z-index. Figure 33-1 shows how this might look in CSS Designer panel and Code view.
../images/466782_1_En_33_Chapter/466782_1_En_33_Fig1_HTML.jpg
Figure 33-1

Properties to position a div so that it floats above other divs in the CSS Designer panel when applied to a class

.float-above{
/*some other properties here*/
position: fixed;
top:200px;
left:10px;
z-index: 100;
}
  • Position : A position can have a value of static, relative, fixed, absolute, or sticky.

  • Static : Elements are static by default and they are not affected by top, left, bottom, or right properties, so the element moves to the normal flow of the page in the browser if it is made larger or smaller.

  • Relative : Positioned normal to its relative position. If you add top, left, bottom, or right properties, it moves away from its relative position in whatever offset direction you set. And other elements may not fill the gap that is left unless they have additional CSS properties of their own.

  • Fixed : As you see in the previous code example, it is positioned relative to the viewport of your browser. Viewport is important in mobile design, as you see in the next section of this chapter. Fixed means it always stays in the same place, even if the page is scrolled. The top, right, bottom, and left properties are used to position the element. Also, unlike relative, it does not leave a gap in the page where it normally would be located. In most cases, you do not need to add a z-index when you work with fixed, but you will see why that property is useful.

  • Absolute : Positioned relative to the nearest positioned ancestor or parent element. If there are no parent elements, the <body> tag becomes the default and moves along with the scrolling page.

  • Sticky : A relatively new CSS3 value that only the most modern browsers support. And it is positioned based on the user’s scroll position. A sticky element could be relative or fixed, depending on the position of the scroll. It is positioned relative until a given offset position is met in the viewport—then it “sticks” into that place (like position:fixed). You must also specify at least one top, right, bottom, or left property for it to work.

Note

In Dreamweaver’s CSS Designer version 2019, sticky does not show up in the options; however, if you type in Code view, then it appears. Refer to Figure 33-2.

../images/466782_1_En_33_Chapter/466782_1_En_33_Fig2_HTML.jpg
Figure 33-2

Properties to position a div so that it floats above other divs in the CSS Designer panel when applied to a class, from the list you can choose fixed or change to another value. You can also type in Code view to get the option of sticky.

Just remember that not all older browsers support the sticky value; make sure to check out the current vendor prefixes on W3Schools.

To learn more about positioning margins with top, bottom, left, and right check out www.w3schools.com/css/css_positioning.asp .

z-index

If you want to ensure that an element overlaps whether you are using the fixed, absolute, or relative position, use a z-index. The z-index only works with positioned elements. The z-index property specifies the stack order of an element (which element should be placed in front of, or behind, the others), just like layers in Photoshop CC or Illustrator CC.

An element can have a positive or negative stack order; a –1 places the <div> tag or element in the back, while a value of 1 places it in front. Be aware that because your website may have many elements, you may need to set a relatively high number, like 100. I find this ensures that the element is in the foreground.

One other item that is useful for cropping the image is the clip property.

Clip

Trims parts of an absolutely positioned element that contains an image in the top, right, bottom, and left; for example, clip: rect(20px,60px,200px,0px);

Other than fixed or absolute, it does not work with other position values or if an overflow property is set to visible.

Using the four rectangle coordinates, you can decide which areas of your image appear or do not appear. This is helpful when an image is larger than the containing element. The cropping of the image is nondestructive and is a better alternative than using Dreamweaver’s Quick Edit tool in the Properties panel, as you saw in Chapter 31.

Note

With model images or light boxes, an image that floats is often initially hidden, so it may require an additional property of display none. Also, to call up the image, you need to use additional JavaScript or jQuery. You can see many easy-to-create examples on W3Schools:

www.w3schools.com/howto/howto_js_lightbox.asp

www.w3schools.com/howto/howto_css_modal_images.asp

www.w3schools.com/howto/howto_css_modals.asp .

Later, on the Hot Glass Tango website, you see how you can use jQuery with Bootstrap to create a basic gallery.

Responsive Media Queries and the View Port

The viewport is an important part of creating websites for mobile devices. It allows you to control the user’s visible area of the webpage. You can find the code for the viewport in the Insert panel in the HTML tab. Refer to Figure 33-3.
../images/466782_1_En_33_Chapter/466782_1_En_33_Fig3_HTML.jpg
Figure 33-3

Use the Insert panel to add metadata and viewport tags

The code looks like this:
<meta name="viewport" content="width=device-width, initial-scale=1">
It is found within in the <head> section of the document. This ensures that when the HTML5 pages are viewed on a tablet or smartphone, the pages scale correctly to match the device; otherwise, they may appear shrunken, and you may have difficulty zooming in and reading them.
  • Meta : Gives the browser instructions on how to control the page’s dimensions and scaling. In this case, its name attribute is viewport.

  • Content : Sets the width of the page to follow the screen-width of the device. This can vary based on devices, but the setting to use is width=device-width.

  • Initial-scale=1 : Sets the initial zoom level when the page is first loaded by the browser. It can also be written as initial-scale=1.0; either way is OK. Figure 33-4 shows how it appears in the Properties panel.

../images/466782_1_En_33_Chapter/466782_1_En_33_Fig4_HTML.jpg
Figure 33-4

The viewport tag in the Properties panel

Whether you are using a laptop, tablet, or smartphone, and regardless of the screen orientation, users prefer to scroll vertically on a webpage. So, you want your pages to neatly fit and match within the screen size. While the viewport is helpful, you still need to take time to create CSS media queries for several devices. To explore media queries thoroughly requires a totally separate book. In Chapter 35, you see how to add media queries quickly using Bootstrap. In the following section you will find basics of how you can link your CSS media queries in Dreamweaver. You can also look at the Hot Glass Tango site to help you further your research for your own site, which likely has many similar media queries.

To begin, if you are starting with a new or existing HTML5 page that you intend to add external CSS to, the first thing that you need to do is go to your CSS Designer panel and add the New or Existing CSS file, as you saw in Chapter 32. Refer to Figure 33-5.
../images/466782_1_En_33_Chapter/466782_1_En_33_Fig5_HTML.jpg
Figure 33-5

Use the CSS Designer panel to add CSS and media queries

You can see how to locate these files and attach them in Chapter 32.

However, this time, you want to ensure that the CSS is specifically for the screen. By default, it was originally set to all types of media, including print. In the optional section, turn down the Conditional Usage (Optional) tab to see this area. Refer to Figure 33-6.
../images/466782_1_En_33_Chapter/466782_1_En_33_Fig6_HTML.jpg
Figure 33-6

Set how you use the CSS for your website

The media is now set to screen from the drop-down menu. You could add more conditions for orientation, such as portrait or landscape by clicking the plus or minus icons. But you do not need to. Later in the chapter, you see how CSS takes care of this within the external file . Refer to Figure 33-7.
../images/466782_1_En_33_Chapter/466782_1_En_33_Fig7_HTML.jpg
Figure 33-7

Set the CSS to be used only for screen

When you click OK, you have code in your CSS like this:
<link href="css/newstyle_jh.css" rel="stylesheet" type="text/css" media="screen">

Notice how an attribute of media="screen" was added to the <link> tag in the <head> section.

So why would you do this? Is not all CSS already for the screen? No, some CSS can be used for printers as well, just as you would print a Microsoft Word or a PDF document, you can use CSS to print HTML pages so that they format neatly. Originally many online catalogs and archived manuscripts were not meant to be published on the web, but for research purposes, viewers may want to print them. CSS with HTML can be a reliable way to keep your documents in a standard format for the viewer to print. You look at this briefly at the end of this chapter, but essentially, you can set separate CSS that is only used for printing devices so that all or certain pages can print correctly when you choose Print or Print Preview. Refer to Figure 33-8.
../images/466782_1_En_33_Chapter/466782_1_En_33_Fig8_HTML.jpg
Figure 33-8

Set the CSS to be used only for print and not for screen

You then have two lines in the <head>, like this:
<link href="css/newstyle_jh.css" rel="stylesheet" type="text/css" media="screen">
<link href="css/ main_print.css" rel="stylesheet" type="text/css" media="print">
You can see how this appears in the CSS Designer panel, and on links on the page. Refer to Figure 33-9.
../images/466782_1_En_33_Chapter/466782_1_En_33_Fig9_HTML.jpg
Figure 33-9

Adding print and screen CSS to a page

For the moment, you focus on the screen CSS.

Before you begin adding media queries, it’s important that you take time in the early planning stages to decide what types of devices and browsers you are going to target. You may not want the exact same layout for each device. This can become apparent in files that have backgrounds or slices. Suddenly, you’ll notice items don’t fit correctly in the same location for each device.

Image Slices and Mobile Devices

As we saw in Photoshop (Part2) and Illustrator (Part3), you can add slices as background images to divs. While this may be OK for images viewed on desktop computers, you must scale in the browser for a tablet or smartphone the images can get really jumbled because the <div> order may change and move around in the device’s browser.

In designing a website, it is critical to see how your background images perform in different browser sizes. For tablets and smartphones, it is better to have repeatable background patterns or a solid color rather than have photographic background images scale accurately at all sizes. In addition, it uses less processing power for those devices and your site loads quicker. For mobile devices, a better use of photographic images is for a gallery or an informational how-to page.

So regardless of whether you are using background images or not, the first thing to do is use grids or columns to show how your basic layout is going to flow.

W3Schools ( www.w3schools.com/css/css_rwd_grid.asp ) has a good example of this type of layout. Another good program to work with is the Gridulator ( www.gridulator.com ) if you need a background to work with in your Photoshop or Illustrator layouts.

Grid view works with box-sizing when you use the *, which covers all tags or elements; for example:
* {
    box-sizing: border-box;
}
.header {
    border: 1px solid red;
    padding: 15px;
}
.menu {
    width: 25%;
    float: left;
    padding: 15px;
    border: 1px solid red;
}

box-sizing: border-box; makes sure that the padding and border are included in the total width and height of the elements when you work with percentages of width.

However, depending on the number of columns, you may want to write it in a more intuitive way. With different classes controlling the layout of each column division; for example, you may write a 12-column layout like this:
 * {
    box-sizing: border-box;
}
.header {
    border: 1px solid red;
    padding: 15px;
}
.row::after {
    content: "";
    clear: both;
    display: table;
}
[class*="col-"] {
    float: left;
    padding: 15px;
    border: 1px solid red;
}
.col-1 {width: 8.33%;}
.col-2 {width: 16.66%;}
.col-3 {width: 25%;}
.col-4 {width: 33.33%;}
.col-5 {width: 41.66%;}
.col-6 {width: 50%;}
.col-7 {width: 58.33%;}
.col-8 {width: 66.66%;}
.col-9 {width: 75%;}
.col-10 {width: 83.33%;}
.col-11 {width: 91.66%;}
.col-12 {width: 100%;}
It is a common practice to use a 12-column grid layout; each column is 8.33% of the total. The total width of the document is 12, or 100%. Depending on your target audience, the largest size of the site may be 1600 pixels or larger. You then apply different column classes to specific <div> tags to move the page around. This affects how each shifts.
<div class=col-3"></div>
In the Hot Glass Tango website, the CSS uses a similar kind of layout:
<div class="col-lg-6 offset-lg-3">

Bootstrap has much of this layout predesigned in the CSS, so all you need to do is make modifications to the layout, which you look at in more detail in Chapter 35.

Once you have designed a rough idea of what you want each layout to look like, the next step is to add media queries.

Media Queries (Mobile-First)

Media queries are useful when modifying your site for a device that has specific screen resolution parameters. They are very similar to the conditions media="screen" that you set up in the HTML page, except that you can set multiple ones inside one external CSS rather than have to write alternate conditions and attach several external CSS files for the screen.

If you are building for desktops, tablets, and smartphones, depending on the dimensions, you create three media queries.
body {
    background-color: green;
/* other base properties*/
}
@media only screen and (max-width: 500px) {
    body {
        background-color: blue;
/* other properties for this size*/
    }
}

The @media only screen and (max-width: 500px) could be considered a break point; if you use this code, the background suddenly changes color when a max-width or maximum width reaches 500 pixels. In this case, there the default or base and the breakpoint which is within its own brackets. Using one media query works OK for two changes; however, you want to design for three. When working with mobile design, it is better to think about the mobile-first approach and then work your way down in the CSS to larger sizes.

Figure 33-10 shows how it can appear in the CSS Designer panel.
../images/466782_1_En_33_Chapter/466782_1_En_33_Fig10_HTML.jpg
Figure 33-10

View and add media queries to CSS Designer

Figure 33-11 show how a page appears in Live mode; you can clearly see the breakpoints.
../images/466782_1_En_33_Chapter/466782_1_En_33_Fig11_HTML.jpg
Figure 33-11

How media queries appear in the Preview panel

body {
    background-color: green;
/*other mobile and default properties for all*/
}
@media only screen and (min-width: 600px) {
    body {
        background-color: blue;
/*other tablet properties*/
    }
}
@media only screen and (min-width: 768px) {
 body {
        background-color: red;
/*other  desktop computer properties*/
    }
}

This time I used min-width or minimum width to alert at what breakpoint the changes occur.

You do this because rather than changing styles when the width gets smaller than 768 pixels (max-width), you should change the design when the width gets larger than 768 pixels (min-width). This makes it a mobile-first design.

You can add as many breakpoints as you require for each device. Sometimes your layout may need some intermediate breaks, but most times, four or five media queries may be all you need, depending on your target audience.

You can also have a set of CSS properties that only apply when the browser window is wider than its height, also called landscape orientation .
@media only screen and (orientation: landscape) {
    body {
/*other properties*/
         background-color: lightblue;
    }
}

This might be an option if the tablet or smartphone is turned horizontally.

As you saw in the earlier CSS of this section class columns can be added this time to each of the media queries.
* {
    box-sizing: border-box;
}
.row::after {
    content: "";
    clear: both;
    display: table;
}
[class*="col-"] {
    float: left;
    padding: 15px;
}
html {
    font-family: "Arial", sans-serif;
}
.header {
    background-color: #9933cc;
    color: #ffffff;
    padding: 15px;
}
.menu ul {
    list-style-type: none;
    margin: 0;
    padding: 0;
}
.menu li {
    padding: 8px;
    margin-bottom: 7px;
    background-color: #33b5e5;
    color: #ffffff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
}
.menu li:hover {
    background-color: #0099cc;
}
.aside {
    background-color: #33b5e5;
    padding: 15px;
    color: #ffffff;
    text-align: center;
    font-size: 1em;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
}
.footer {
    background-color: #0099cc;
    color: #ffffff;
    text-align: center;
    font-size: 0.5em;
    padding: 16px;
}
/* For mobile and smartphones: */
[class*="col-"] {
    width: 100%;
}
@media only screen and (min-width: 600px) {
    /* For tablets: */
    .col-tb-1 {width: 8.33%;}
    .col-tb-2 {width: 16.66%;}
    .col-tb-3 {width: 25%;}
    .col-tb-4 {width: 33.33%;}
    .col-tb-5 {width: 41.66%;}
    .col-tb-6 {width: 50%;}
    .col-tb-7 {width: 58.33%;}
    .col-tb-8 {width: 66.66%;}
    .col-tb-9 {width: 75%;}
    .col-tb-10 {width: 83.33%;}
    .col-tb-11 {width: 91.66%;}
    .col-tb-12 {width: 100%;}
}
@media only screen and (min-width: 768px) {
    /* For desktop: */
    .col-1 {width: 8.33%;}
    .col-2 {width: 16.66%;}
    .col-3 {width: 25%;}
    .col-4 {width: 33.33%;}
    .col-5 {width: 41.66%;}
    .col-6 {width: 50%;}
    .col-7 {width: 58.33%;}
    .col-8 {width: 66.66%;}
    .col-9 {width: 75%;}
    .col-10 {width: 83.33%;}
    .col-11 {width: 91.66%;}
    .col-12 {width: 100%;}
}

Again, the base (global) and mobile settings are taken care of first; followed by the tablet, which is the next largest; and finally, the desktop computer.

Using media queries, you can see how a webpage on the Hot Glass Tango site changes when the browser window is compressed and expanded. With Bootstrap, additional sizes of even larger screens were added.

For more information, visit www.w3schools.com/css/css_rwd_mediaqueries.asp .

Scaling Images

Once you have worked out each of your layouts for each breakpoint and added colors or background images to your elements and <div> tags, the next step is to add images to your page. Unlike a static desktop site where images may remain roughly the same size, images for a mobile site need to shrink and/or grow as the browser changes for each device. In some cases, such as the tablet and smartphone, you may want to exclude or have low-res background images to speed download to the browser. You may still want your viewers to see the product images. You can scale your images using CSS. An <img> tag can be set in CSS to
img {
width:100%;
height: auto;
}

This way, the image scales up or down and the height scales proportionately along with it. If it scales upward too much, the image loses its quality, which is not what you want.

So, the best choice is to change it to the property max-width with a value of 100%.
img {
max-width:100%;
height: auto;
}

Max-width stops the image from scaling beyond 100%, but it can be scaled down, which is OK when it comes to quality.

Scaling a div with a Background Image

A background image can also be scaled. In a <div> or semantic element, you can use properties such as background-repeat and background-size to control how the image expands and contracts. This is good if you want to use it with CSS animation.
div {
    width: 100%;
    height: 400px;
    background-image: url(images/img-name.jpg);
    background-repeat: no-repeat;
    background-size: contain;
    border: 1px solid red;
}

Setting the size to "contain" lets the background image scale and tries to fit the content area while maintaining the aspect ratio.

Remember, a setting of no repeat stops the image from repeating in the background and constrains its size, keeping it always visible. If you want the background to fill the area and are not worried about distortion or cropping, then background-size: cover; is a good option; however, part of your image may be clipped with this setting. If you have more than one image in the background, you can use them together.
background: url(images/img_one.gif), url(images/image_two.jpg);
    background-repeat: no-repeat;
    background-size: contain, cover;

Loading a Different Image Based on Media Queries

Regardless of whether the image is in the background or an <img> tag, sometimes you don’t want to load the same image on a smartphone or a tablet due to how the image flows on the page. You can add different backgrounds to your media queries depending on what device you are targeting; for example:
body {
    background-repeat: no-repeat;
    background-image: url(images/img_small.jpg);
/* default and mobile*/
}
/* For width 400px and larger: */
@media only screen and (min-width: 400px) {
    body {
       background-image: url(images/img_large.jpg);
    }
}

Remember to keep using the mobile-first method and test your images in different browsers and devices to make sure that they are changing and shifting correctly.

Note

Another option is to use min-device-width, which checks the width of the actual device rather than the width of the browser (min-width). Keep in mind that if you are doing testing on your desktop computer, min-width shows you the changes as you expand and contract your browser; but with min-device-width, you not see the contraction unless you are testing on specific devices of that size.

@media only screen and (min-device-width: 400px) {
    body {
        background-image: url(images/img_large.jpg);
    }
}

This is optional; for now, just stick with min-width as I did for Hot Glass Tango.

Another option with mobile design is the <picture> element, which was discussed in Chapter 31. See www.w3schools.com/css/css_rwd_images.asp .

As with images, you can scale video using a similar process; you look at this in Chapter 36.

Dreamweaver offers Bootstrap, a CSS library, so you do not have to create your entire mobile-first web design from scratch. Dreamweaver offers some helpful examples that you can use in the File ➤ New and Insert panel, which takes away a lot of the labor of building a new layout each time and speeds up the design process. You’ll look at how you can access the Bootstrap framework in Chapter 35.

If you don’t want to use Bootstrap, you can use some of the responsive design snippets in the Snippets panel. Refer to Figure 33-12.
../images/466782_1_En_33_Chapter/466782_1_En_33_Fig12_HTML.jpg
Figure 33-12

The Snippets panel offers some responsive snippets for the design of mobile sites

In addition, you can use Dreamweaver’s templates to speed up the process of working with mobile design; you look at those in Chapter 35, but first let’s finish up with the CSS.

Column Count

Another CSS3 feature that you can add to a <div> or semantic element is column count. As with any tag, you can add images to flow along with the text or as a background. Columns can be adjusted by their count or the number of columns they have. This can be altered each time you set a new media query. You might style your text in a laptop to have a column count of 3, a tablet a column count of 2, and a smartphone a column count of 1, and then the images flow with the text to fit that layout. Note that the other properties of the columns are fill, gap rule, span, and width.
div{
column-count: 3;
}

For more information, visit www.w3schools.com/cssref/css3_pr_column-count.asp .

CSS for Print with CSS Designer Panel

As with mobile devices, it is a clever idea to design some CSS so that most people could successfully print your webpages with their home printer on a letter-sized sheet (8.5×11).

As you saw in Figure 33-8, with the CSS Designer panel, you can add another external CSS file to your head section for print, in the Conditions section of the Attach new or existing CSS file dialog box as seen earlier in Figure 33-5.

With print, you don’t have to add various sized media queries; however, make sure that the pages neatly format so that they print successfully on a portrait letter-sized page.

You can look at the example of the CSS in the Hot Glass Tango website’s colorsglass.html and main_print.css. Because it is set to a print media, you never see its effects in the screen or browsers. The only time you preview it is when you choose File ➤ Print Preview in the browser. This gives you an idea of how the layout appears. Now you might think that in a paperless society, web designers should only focus on the mobile design. There may be important records, tables, and even images a person may want to print out from a specific page on a website in color or black and white.

When working with webpages, in a variety of viewport sizes, none of these may be suitable when you print the page on many sheets of paper. In this case, you need to create a fixed width since paper is not fluid. In some cases, Bootstrap has some prebuilt media widths set like a min-width of 576 pixels with various properties applied. But you may need to adjust this in your own CSS file, depending on the printer and margins you require. If you only want to print out certain areas of a page, you can exclude those <div> tags or elements with an additional class, such as
div{
display:none;
}

Now that element is completely removed from the page. This might be good for removing banners and navigation that the viewer does not want to print.

As an added feature, if you want some background images to only print in black and white, you could change the image source to the linked image that is black and white or a simplified line drawing that takes up less toner.
.banner{
background-image: url('img_bw.gif');
}
One other formatting tip is to use the page break.
page-break-after: always;

I find this property useful if I am concerned about text breaking from the heading or after a specified element. Other related properties are page-break-before:always; (before a specified element) and page-break-inside:avoid; (if possible avoid a break inside of the element).

Choose File ➤ Print Preview from your browser if you need to see if your pages are formatting correctly.

Now that we have finished our main discussion on CSS and images as they relate to mobile design, let’s see how images interact with the third type of coding, known as JavaScript, along with Dreamweaver CC and its panels.

Summary

In this chapter, you looked at mobile-first design and some CSS, such as floats, media queries, and column counts that allow you to scale your images, <div> tags, and semantic elements for the screen. You also saw that CSS can be used for print media so that your images look their best no matter which media queries you use.

In the next chapter, you take a brief look at JavaScript and how it interacts with images in Dreamweaver.