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_32

32. Working with CSS

Jennifer Harder1 
(1)
Delta, BC, Canada
 

In this chapter, you look at how to work with CSS, linking CSS, and what you can use to enhance your images and turn them into animations using CSS.

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 .

While in a file’s <head> tag, you will look at another way to add images or color to the backgrounds of the tags (rather than directly into the <div> tag or semantic element). You can link to internal or external CSS (Cascading Style Sheet) to format and display the tags or “bones” in your HTML files body. Using media queries, these backgrounds are interchangeable when viewed on different browsers or mobile devices.

CSS Inline Internal or External Styles?

While a whole book could be written on CSS itself, and there are many good reference books available formatting properties, the focus of this section of the book is to look at how that formatting (or properties) can be applied to images that appear as a background or boarder within the tag itself.

A good reference to see how CSS works is W3Schools ( www.w3schools.com/css/ ). They have many simple tutorials that you can observer and copy directly into Dreamweaver CC’s Code view and edit yourself.

Let’s briefly review three ways that CSS can be added or linked to an HTML5 webpage.

Inline CSS

The first way to add CSS is directly as an attribute of the tag or inline. Inline CSS downloads quickly because it is directly on the page viewed in the browser and it is not linked to an external CSS file. Inline has advantages and disadvantages. It can be used to apply a special style attribute to a single HTML element, such as <h1> or <body> tag. With code, you can see a background image and color added to the <body> tag.
<body bgcolor="#E4D5E9" background="images/background1.png">
Other conteent on the page...
</body>

Here the color is added as a fallback in case the image becomes unlinked or cannot display for some reason. The viewer at least sees some color. Also, background images do not require alt tags because their purpose is only to enhance the website, not to provide information.

If you don’t want to type in Code view, you can select the body tag and use the Properties panel to select the Page Properties button. Refer to Figure 32-1.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig1_HTML.jpg
Figure 32-1.

The page properties in the Properties panel allow you to edit some inline CSS

The Page Properties dialog box appears whether you are in the HTML tab or the CSS tab. Appearance (HTML) allows you to add a background image and a background color. Color can also be applied to text and links. You can adjust the margins on the left and the top. You can also adjust the width and height. Refer to Figure 32-2.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig2_HTML.jpg
Figure 32-2.

The page properties Appearance HTML dialog box area allows you to add inline CSS

Press OK to confirm these changes.

Note

Color in Dreamweaver can be written in three ways: RGBa, hex code, or HSLa, if you don’t know the exact numbers you can use the color picker and eyedropper that appears in any of the color pullouts. Only hex code works with inline CSS; however hex does not allow for transparency or alpha filter (a) as the other color modes do. The other colors modes and hex work internal and external CSS which you look at shortly. Refer to Figure 32-3.

../images/466782_1_En_32_Chapter/466782_1_En_32_Fig3_HTML.jpg
Figure 32-3.

The Color Picker in Dreamweaver is similar to what you saw in the other Adobe programs

The choices are RGBa (red, green, blue and alpha transparency), hex or hex code (written with hashtag number sign (#)), and HSLa (hue, saturation, luminosity, alpha), which also has an alpha channel. You can also enter actual words, like red or green, to get a variety of colors. Most modern browsers accept alpha channels and transparency; however, if you find you’re running into color issues on a browser, stick with hex code, which you can easily find using the color picker.

CSS is good for formatting each tag individually on a single HTML page, but there are several issues that you can run into using inline CSS.
  • You must format each tag separately, which can lead to errors if you must type or copy and paste each formatting into each tag.

  • The amount of formatting in each tag could become quite lengthy once you start adding font colors, margins, padding, or other styling.

  • If you want to have similar styling on another HTML page, you must copy and paste it into the next document; this wastes time and can lead to errors.

  • Another issue is scope, which refers to when one CSS style overrides another CSS style because it is closer to the tag itself. Anything inline is as close as you can get to the tag, so any CSS that comes before is overwritten.

Use inline CSS sparingly and only if you plan to override some settings for just that page. Remove any inline CSS from your HTML5 page if you do not plan to use it. Most of it is located via the Properties panel ➤ Page Properties dialog box ➤ Appearance (HTML) tab, but you may have to scan through the code in Code view or use Tools ➤ Clean up HTML to remove obsolete tags if you are working from a client’s files. Refer to Figure 32-4.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig4_HTML.jpg
Figure 32-4.

Clean up your HTML or XHTML to remove inline styles or obsolete tags

If you plan to use the CSS more than once on a page, a better option is to use internal or linked external CSS.

Internal CSS

In Dreamweaver CSS, there are several ways to apply CSS. The first example you saw was inline. The second being internal, which is used to define a style for a single page. Internal CSS always appears in the <head> tag of the document, usually in the <title>. All styles appear between the <styles> </styles> tags.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Home Page</title>
        <link rel="shortcut icon" type="image/x-icon" href="images/favicon.ico" />
        <style type="text/css">
        body {
    background-color: #E4D5A9;
    background-image: url(images/background1.png);
}
    </style>
</head>
<body>
Some Content Here...
</body>
One way to do this is to select the body tag and from the Properties panel, and then click the Page Properties button and select the Appearance CSS tab. Refer to Figure 32-5.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig5_HTML.jpg
Figure 32-5.

Add inline CSS to a page

This automatically creates some internal CSS in the head for the <body> tag. You can also alter the font, font size, text color, image repeat options (repeat, repeat-x, repeat-y, or no repeat), and the margins. Refer to Figure 32-6.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig6_HTML.jpg
Figure 32-6.

The page properties Appearance CSS dialog box area allows you to add inline CSS

Click OK to apply the changes.

Other CSS that you can affect is found in the Links (CSS) and Headings (CSS) tabs, where you can alter text style and color in the <body> tag.

Tip

For the background image, the url('images/image.jpg') can either have single, double or no quotes around the link, either way is OK to right in Code view, but make sure the link is correct or you will not see the image.

Note

Trace image is an inline code that is used if you are designing a website and need to use a temporary background image to design or CSS layout over top. Once you are done, remove this information from the <body> tag, as it is only for design purposes. Refer to Figure 32-7.

<body tracingsrc="images/120x120.gif" tracingopacity="100">
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig7_HTML.jpg
Figure 32-7.

Page Properties allows you to temporarily add an image for tracing and design only while working on your website

CSS Designer Panel

Another way to add inline CSS is to use the CSS Designer panel. This panel allows you to create CSS styles, add a source internal or external linked file, and adjust the media queries along with their selectors and their properties, as seen in Figure 32-8.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig8_HTML.jpg
Figure 32-8.

CSS properties panel helps you link and edit the CSS that is attached to your webpages

The first thing to do is to make sure that the panel is set to the All tab, since you want to see all CSS in the document; in the example shown in Figure 32-9, there is an internal CSS <style> but no external.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig9_HTML.jpg
Figure 32-9.

An internal style sheet is found using the CSS Designer panel

If you did not have an internal style sheet, click the plus (+) icon in the Sources tab. The minus (–) icon removes any unwanted internal CSS styles. Once the plus icon is clicked, you can choose from the drop-down menu to create a new or attach an existing CSS file (external), or define in a page (internal). Refer to Figure 32-10.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig10_HTML.jpg
Figure 32-10.

Adding an internal style sheet using Define in Page

Define in Page creates the <style> tags and adds it in the <head> tag in Code view. If there is already an internal style when you choose this option, it does nothing since the <style> tag is in place.

You can see in the CSS Designer panel in Figure 32-9 that a <style> has been added to the Sources section.

In the CSS Designer panel, skip over the Media Query tab since you are not designing for a mobile site yet. You look at this in more detail in Chapter 35. Move down to the Selectors tab. This is where you define your CSS selectors for your internal source that apply to tags in your current document. You can move the upper and lower handle in the tabs if you need more room. Refer to Figure 32-11.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig11_HTML.jpg
Figure 32-11.

Selectors tab in CSS Designer

Click the plus icon to add a selector. This could be <tag> ID or class. If you type in the word body, Dreamweaver gives you hints if you are not sure of the exact wording of the tag. As you type more letters, the choices narrow down to a few relevant rules. Refer to Figure 32-12.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig12_HTML.jpg
Figure 32-12.

Type in a selector

Then select body from the list.

Later, you can filter through the list with the search text box if you have a lot of rules.

The new body rule is now in the Selectors section; you find it in the Code view in the styles tag. If you realize you made a mistake, you can select it and click the minus (–) icon to remove it and type it in again. Refer to Figure 32-13.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig13_HTML.jpg
Figure 32-13.

The Selector rule now appear in the list and in the <styles> in Code view

With the word or tag body rule selected in the list, move down to the Properties tab and click the plus (+) icon. Refer to Figure 32-14.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig14_HTML.jpg
Figure 32-14.

Add properties to the selector in the CS Designer panel

This adds a field for a property and value that you can enter. Dreamweaver helps you with a list of properties so that you can find the correct one, in this case, background color. Refer to Figure 32-15.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig15_HTML.jpg
Figure 32-15.

Find the correct properties to add to your body tag

When you find the correct one, "background-color", select it.

Then select the value text area and add hex code with a # symbol. Refer to Figure 32-16.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig16_HTML.jpg
Figure 32-16.

In the Properties tag add in a color for the background value

Note

Dreamweaver does not bring up the color picker at first in the CSS Designer panel, so make sure you know what the color code is before start typing. I find that a clever work-around is to instead type the color value in Code view rather than in the CSS Designer panel as this bring up the color picker and other helpful hints that CSS Designer does not always show. Refer to Figure 32-17.

../images/466782_1_En_32_Chapter/466782_1_En_32_Fig17_HTML.jpg
Figure 32-17.

Certain hints or dialog boxes do not always show up in CSS Designer so sometimes you may find it easier working in Code view

If you use Code view after you have selected the color and pressed the Enter key to confirm it, Dreamweaver may not add a closing properties semicolon.
background-color: #E4D5A9;

You need to do this before you move on to the next property. The CSS Designer panel does, however, add the semicolon for you.

Only once the background color CSS is locked in after you create another tag or selector in CSS Designer Panel the Color Picker dialog box becomes available, and you can now alter it by selecting the tab. Refer to Figure 32-18.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig18_HTML.jpg
Figure 32-18.

Only once another tag is created can access the color picker

While the body tag is selected, you can add properties such as the background-image by clicking the properties plus (+) icon; the minus (–) icon allows you to remove any unwanted properties when they are selected. Refer to Figure 32-19.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig19_HTML.jpg
Figure 32-19.

Add properties to the body tag

Finding the URL may be easier in Code view because you have the browse feature available right away if you cannot remember the exact link of the file. Refer to Figure 32-20.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig20_HTML.jpg
Figure 32-20.

Add properties to the body tag

Once confirmed in the CSS Designer, you can then change the background images link as required. Refer to Figure 32-19.
body {
    background-image: url(images/background1.png);
    background-color:#E4D5A9;
}

Adding Other Background Properties

Clicking the More button (see Figure 32-19) in the CSS Designer Properties tab reveals more options or properties.

Background images have properties or values such as whether the images tile or repeat.
  • background-repeat: repeat; This is the default and repeats vertically (y) and horizontally (x).

  • background-repeat: repeat-x; This repeats the background along the x coordinate.

  • background-repeat: repeat-y; This repeats the background along the y coordinate.

  • background-repeat: no-repeat; This leaves only one image and it does not repeat.

The “space” and “round” properties affect how the background repeats. CSS background-images can have more than one image in the background.
body {
    background-image: url(images/backgroundimage1.png), url(images/backgroundimage2.gif);
    background-repeat: no-repeat, repeat;
    background-color: #cccccc;
}
The following properties are added when background-repeat: no-repeat; is used.
  • background-position: right top ; Other placement words are right, bottom, and center. You can also use pixels (2px 2px) or percentages(50% 50%) for placement. The first value is the vertical (x) and the second is the horizontal (y). A shorthand example of this is

background: #ffffff url(images/glass.png) no-repeat right top;
  • background-attachment: fixed; Specifies that the background image should be fixed (does not scroll with the rest of the page). Scroll is the default, and there is the local option that scrolls with the tag’s contents.

  • background-origin: content-box; The background-origin property specifies the origin position (the background positioning area) of a background image. This property has no effect if background-attachment is fixed. It is often used if one or more images are found in the background. One might be set to value of content box and the other to border box or padding-box.

For more information on these properties, refer to https://www.w3schools.com/cssref/css3_pr_background-origin.asp .
#wrapper {
    border: 10px double black;
    padding: 25px;
    background: url(images/background1.gif), url(images/background2.gif);
    background-repeat: no-repeat;
    background-origin: content-box, padding-box;
}
The following are CSS3 elements, so they are relatively new but work in some older browsers.
  • background-size: 300px 100px; Specifies the size of a background image with "auto" and in pixels or percentages 50%, 50%. You can also set it to a value of contain to keep it visible within a boundary of the element. A value of cover allows the image to resize within the element to cover that area. It is often used when the background is set to no repeat, and it can be used with more than one image in the background. You may need to add vendor extensions to make these run correctly, which you can view at www.w3schools.com/cssref/css3_pr_background-size.asp .

  • background-blend-mode: lighten; Defines the blending mode of each background layer (color, image, or both). It is like the blend filters you see in Photoshop, Illustrator, and Animate. These values are not supported by Internet Explorer or Edge. The following are the available options:
    • normal (the default)

    • multiply

    • screen

    • overlay

    • darken

    • lighten

    • color-dodge

    • saturation

    • color

    • luminosity

For more information, visit www.w3schools.com/cssref/pr_background-blend-mode.asp .
  • background-clip: padding-box; Defines how far the background (color or image) should extend within an element.

Background Image Gradients

The CSS background-image property can also create gradients that are liner or radial and repeat by percentage in the background of your website. However, be aware that even though the word image is used, there may or may not be any actual image URLs (PNG, GIF, JPEG) within the parentheses, only colors that are being drawn by the CSS the browser. Images and gradients (linear and radial) can be combined, although they may not show up in every older browser; for example,
.background-main{
    background-image: url(../images/background2.png),url(../images/background1.png), -webkit-linear-gradient(270deg,rgba(255,0,0,0.00) 73.58%,rgba(255,110,0,1.00) 100%);
    background-image: url(../images/background2.png),url(../images/background1.png), linear-gradient(180deg,rgba(255,0,0,0.00) 73.58%,rgba(255,110,0,1.00) 100%);
    background-blend-mode: lighten, normal, normal;
    background-repeat: repeat-x;
}
Figure 32-21 shows an example of linear gradients in the CSS Designer panel. Notice how the color picker alters to add a gradient slider so that you can set color points.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig21_HTML.jpg
Figure 32-21.

A gradient with opacity can be altered in the color picker

Radial gradients, although they appear in the Design view while editing, do not allow the same color picker choices, so you may have to edit by hand in Code view. Refer to Figure 32-22.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig22_HTML.jpg
Figure 32-22.

Edit radial gradients in Code view only

More information on gradients is at www.w3schools.com/css/css3_gradients.asp .

Note

There are other settings: initial and inherit. The initial keyword is used to set a CSS property to its default value or override. The inherit keyword specifies that a property should inherit its value from its parent element. Elements are sometimes affected when one or more CSS properties are combined with inline styles in the tag (see reference to scope in Inline CSS section in this chapter) and how it inherits it styling. Initialvalue: is a new setting is CSS3 and this property may not work in older browsers.

Enabling or Disabling CSS Properties

With the property selected, you can enable or disable (turn on or off), or remove the property entirely with the Trash icon. A property that is disabled appears with CSS comment quotes around it.
/* [disabled]background-image: url(images/background1.png); */
This is like the way that you use layers or show/hide in Photoshop, Illustrator, and Animate. Refer to Figure 32-23.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig23_HTML.jpg
Figure 32-23.

Enable or disable layer properties

Clicking the disable symbol again enables it and returns the CSS onto the page in Design view.

Adding CSS to Other Tags and Elements

In this next section you will look at how CSS can be applied to various HTML tags and semantic elements.

Tags

There are many other CSS properties and values that you could add to the <body> tag that would affect the font or styling of links. However, the body tag is not the only tag that you can add CSS inline styles to.

Any tag selector can be added between the <style> tags in the head; refer to Chapter 31 if you need to review HTML5 elements. For example, if you wanted to target the <main> or <footer> elements, you could write
<style>
main {
    background-color: #111111;
    background-image: url(images/background1.png);
}
footer {
    background-color: #222222;
    background-image: url(images/background2.png);
}
</style>
Both would have a different background and default color. If you wanted both to have the same background and default color, then you could write
<style>
main, footer {
    background-color: #111111;
    background-image: url(images/background1.png);
}
</style>

Combining or separating styles is useful, and you can do this with all tags. In CSS, tags are always written with their full name. However, as you saw with semantic elements in Chapter 31, some tags, like <div>, can be used more than once on a page, like <header>, <footer>, <article>, or <section>.

IDs
You may only want to target a specific <div> or semantic element so you could use an ID instead. IDs are unique, and they can only be used once per page. In CSS, the ID always starts with a # symbol, but it is written without the # when referenced in the tag.
<style>
#wrapper {
    background-color: #111111;
    background-image: url(images/background1.png);
}
</style>
Now only that div or sematic element is affected.
<div id="wrapper"> </div>
You can see how this looks in the Properties panel where the ID was added. Refer to Figure 32-24.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig24_HTML.jpg
Figure 32-24.

The Properties panel with div ID

Class
When you want to target more than one tag with CSS, you can use a class. Unlike IDs, which can only style a single element, classes can be used as many times as you want on page. In CSS, a class always starts with a period (.), but it is written without the period when referenced in the tag.
<style>
.image-glass {
    background-color: #111111;
    background-image: url(images/background1.gif);
}
</style>
Now in the following <div> or semantic elements the class could be added:
<div class="image-water"> </div>
<section class="image-water"></section>

Those without the class are never altered by the CSS.

A class can be applied when a tag is selected in Code view; you can use the Properties panel to select the class from the list. Refer to Figure 32-25.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig25_HTML.jpg
Figure 32-25.

The Properties panel add a class to a div or attach a style sheet

The default is set to none. From here you can also rename your style. This changes both the style and tag. Refer to Figure 32-26.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig26_HTML.jpg
Figure 32-26.

Rename the selected style

Also, you can attach an external style sheet from this area in the Properties panel.

Classes and tags can work together; for example, in your CSS, you can apply some styles to the tag and one or more classes as attributes.
<style>
section {
color: red;
}
.image-glass {
    background-color: #111111;
    background-image: url(images/water.gif);
}
.small-text {
font-size: 7px;
}
</style>
The CSS added to the body may look something like this:
<div class="image-water small-text"> </div>
<div> </div>
<section></section>
<section class="image-water"></section>

When text is added, it is sized and colored in different ways because of the way the classes target the link.

Pseudo Class Selectors

One final selector that you may come across is the pseudo class, which is a bit more complex or advanced to work with. Essentially, it defines a special state of an element that can be altered by adding a keyword to a selector.

For example, it can be used to style:
  • an element when a user mouse hovers over a link, the color alters

  • an element when it gets focus, like an input tag

While these elements may not all have background images, you may want to use them within a div that you want to change in some way when you hover, such as the color of a button or a div element.
<style>
.nav-box {
    background-color: green;
    background-image: url(images/background1.png);
    color: white;
    padding: 25px;
    text-align: center;
}
.nav-box:hover {
   background-image: url(images/background2.png);
    background-color: blue;
}
</style>

If you applied this class (.nav-box) to a <div> tag, when your mouse hovers over it, the image in the background changes. Pseudo classes can be used in some very creative way, which you’ll look at again. For more information, visit www.w3schools.com/css/css_pseudo_classes.asp .

To access the base class or the pseudo class for a tag, use the Properties panel to select the base class first.
<div class="nav-box"> <div>

External CSS

So far you have looked at inline CSS and internal CSS. However, with internal, while it is much easier to work with because all the styling is in one location, you still have two issues.
  • The more CSS you add to the page the more room it takes up. It takes the page longer to load.

  • You want to use the CSS on other HTML pages, so you must copy and paste the CSS into those pages, which wastes time, and some of it you may not want to use on all pages so now you have to spend time removing those lines of code.

If you are going to use CSS in multiple pages, it is far better to create an external style sheet and link it to the page. External stylesheets can define the style for multiple pages on your site. When you edit one linked file, you can change the property values of all linked pages. Bear in mind, however, that any internal CSS left on the page overrides the external CSS because it is closer to the tag. If you do not remove the internal styling first you may wonder, why your new styles do not format correctly.

Use internal CSS only for pages that require a very specific styling, such as overriding the background or a link color just for that page; otherwise, it is best to keep all CSS in a main external file.

To create an external CSS file, you can use Dreamweaver’s CSS Designer panel in the same way that you used it to create your internal style sheet and format it. However, there are some key differences. If you are worried about losing any CSS in the <styles> area, I recommend that you copy, paste, and save this text in a .txt file like Notepad++. Then if you remove the internal styling or need to copy it into the external file at another time, it is not lost.

CSS Designer Panel

In the CSS Designer panel, select the <style> if it is still in your file and press the minus key in the Sources tab to remove it. Refer to Figure 32-27.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig27_HTML.jpg
Figure 32-27.

Remove internal styles

Your page goes back to base settings. If you saved a backup of the CSS you’re OK; otherwise, Edit ➤ Undo should return it, so you can copy it into a temporary file.

With the internal CSS gone, in the Sources tab, click the plus (+) icon and choose Create A New CSS File, or Attach Existing CSS File, if you already have created one. Refer to Figure 32-28.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig28_HTML.jpg
Figure 32-28.

Create or add an existing style sheet

Create A New CSS File allows you to add a new file. Leave the setting at Link. Click Browse to locate a location for the new CSS file, as seen in Figure 32-29.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig29_HTML.jpg
Figure 32-29.

Create a New CSS File dialog box

The Conditional Usage (Optional) tab refers to how you plan to use your CSS; besides different media types it can be used for screen and for print so that the client can print correctly formatted sheets when they print from your website. You’ll look at this option later in more detail. For now, leave it unselected and click Browse. Give your CSS file a name and save it with your HTML files in the site root folder or in its own CSS folder. Refer to Figure 32-30.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig30_HTML.jpg
Figure 32-30.

Create a New CSS file and save it in the CSS folder to stay organized

When I built the Hot Glass Tango website, I found that as the CSS became more complicated, I needed to have more than one CSS file. To keep organized, I stored all the CSS in one folder.

When done, click Save to return to the original dialog box. Refer to Figure 32-31.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig31_HTML.jpg
Figure 32-31.

The new CSS file is linked

You now have a location that your new file is saved in a CSS folder. Click OK.

You not see the effects of the new CSS file right away since it is currently empty, however, you know that it linked to you HTML file with three indications.

In the <head> tag, you see the link something like this:
<link href="css/newstyle_jh.css" rel="stylesheet" type="text/css">
In the top of the document, you see a new link icon to that file. Refer to Figure 32-32.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig32_HTML.jpg
Figure 32-32.

Attaching an external CSS

In CSS Designer, a new source is added to the file. Refer to Figure 32-33.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig33_HTML.jpg
Figure 32-33.

Attached an external CSS in the CSS Designers panel

To access the CSS external file, you can click the CSS icon file link at the top of your page. Or in the Files panel, locate the new CSS file and once you locate it here, double-click to open. Refer to Figure 32-34.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig34_HTML.jpg
Figure 32-34.

CSS is attached to a webpage as an external file

Either way the external CSS file is blank except for a charset rule.

Click line 2; this is the point where you add your CSS or what you have already created. If you want to practice adding the CSS for color and background images using CSS Designer, refer to the section on inline CSS as the process is basically the same except that now you are adding it to an externally linked file, so you do not require the CSS <style> tags anymore. The linking takes place through the <link> tag in the <head> of your document.

In my example, my copied text might look something like Figure 32-35.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig35_HTML.jpg
Figure 32-35.

Some CSS is added to an external style sheet

As you can see, there are no <style> tags because they are not required. Save the file after each change and then return to the Source Code tab, as seen in Figure 32-43.

You might notice that only the colors are only coming in. This is because you have placed the CSS in a folder rather than in the root site and so now the links are slightly different. You can make a correction by adding a (../) and this should resolve the issue and return the images. This is sending me into the correct folder, but you may have to adjust this differently, depending on how you set up your site. Refer to Figure 32-36.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig36_HTML.jpg
Figure 32-36.

Altering the link of the background image file

Save the CSS and return to the Source Code tab.

Now that you have created an external CSS file, you can create HTML5 pages and with CSS Designer choose Attach Existing CSS file. This follows the same process as Create A New CSS File, except this time, you browse and locate the existing file and attach it to your HTML document. Refer to Figure 32-37.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig37a_HTML.jpg../images/466782_1_En_32_Chapter/466782_1_En_32_Fig37b_HTML.jpg
Figure 32-37.

Attach Existing CSS File dialog box

When done, make sure to add as Link and click OK, and the CSS that was created be linked.

You can continue to edit the CSS with Code view or CSS Designer and continue to add background images.

File ➤ New ➤ CSS

It should be noted that if you are a designer and you plan to create a new CSS file that you don’t want to attach right away. You can choose File ➤ New ➤ CSS from the New Document dialog box and click Create, which brings up a new CSS file that you can save to the root directory or a folder, but it is not linked to any HTML file until you create a link in the <head> of a document. Refer to Figure 32-38.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig38_HTML.jpg
Figure 32-38.

Creating a blank CSS document for a new project without attaching it to a file

What Is CSS3?

So far, you have looked at CSS and learned how to attach it to an HTML5 document, and to add background and color images to <div> and semantic elements. I’ve said that some CSS is CSS3, but what does that mean and what other features does CSS3 have to offer?

Like HTML5, the fifth version of HTML, CSS3 is the third version or revision of Cascading Style Sheets. As multimedia changes on the web for different viewing devices, new innovations like animations, transitions, color filters, gradients, and effects like rounded corners have been added. Like HTML5 not all older browsers support the new CSS3 standards, so before using a new feature or property, it is important to check whether it is compatible with the browsers that many of your viewers use. Refer to www.w3schools.com/cssref/css3_browsersupport.asp and https://caniuse.com .

There are also ways to add some backward compatibility to a website, such as an HTML5 shiv or JavaScript to emulate or compensate for how a CSS3 property or HTML5 tag behaves on a website and make it act like the modern version, or at the very least alert the user.

Refer to www.w3schools.com/html/html5_browsers.asp and https://modernizr.com .

It should be noted that within Dreamweaver CC in CSS Snippets, you can also find a few helpful resources, such as Eric Myers CSS Reset and HTML5 Stylesheet Reset.

Remember to click the Edit Snippets button and copy the insert code. Or with a new file, use the arrow insert key on the Snippets panel to add the code on a blank CSS or HTML5 page. Refer to Chapter 31, if you need to review this panel. Refer to Figure 32-39 .
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig39_HTML.jpg
Figure 32-39.

Resources in the Snippets panel for working with CSS

Just be aware that some of the snippets are a few years old, so take time to compare them to more recent versions online to see if you should add any other CSS to the file. You may then want to add code as an updated version of the snippet, calling it something like (YourName) CSS Reset. To do so, highlight only the code that you want to be part of your snippet and click the New Snippet button to add it to the library. Also make sure to save a backup elsewhere, in case Dreamweaver CC should every overwrite it during an upgrade.

For the Hot Glass Tango website, I used the built-in resets that came with the Bootstrap files in the CSS folder when I created my layout; you look at this in more detail in Chapter 35.

Having said that, I believe that in backward compatibility there is only so far back you can go, and at some point, you or your clients need to upgrade their browser to embrace the latest changes. From what I have noticed, Internet Explorer, or Edge, is usually the last to accept new CSS3 or HTML5 upgrades, so I would probably not design lower than Internet Explorer 9. Also, if you find that some of your clients’ tablets and smartphones are not accepting some CSS3 when you design your site for responsive media, you may want to leave out CSS3 in that part of the media query and focus on the padding, margins, and text formatting rather than have all queries function the same. You look at media queries in more detail later.

Now let’s continue to look at some CSS examples for working with images in Dreamweaver, some of which involve using CSS3.

Applying CSS to the <img> Tag

Whether you are working with an <img>, <div>, or any semantic element, they can all be placed and adjusted on the page using the CSS properties width, height, margin (the space outside), padding (the space inside), and border (edge of box). An example is the box model, as seen in the following code:
div {
width: 300px;
height:300px;
border: 10px solid green;
padding: 10px;
margin: 10px;
}

These properties have been around for a long time for styling. You can further adjust each side of a border, padding, or margin by value as margin-bottom, margin-left, margin-right, or margin-top.

This order can be applied to padding and borders so that every side is a slightly different thickness, border color, or style.

You can see in the CSS Designer panel how you can easily adjust this; look at the Properties tab. Refer to Figure 32-40.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig40a_HTML.jpg../images/466782_1_En_32_Chapter/466782_1_En_32_Fig40b_HTML.jpg
Figure 32-40.

Altering the width, margins and padding in CSS Designer

You can alter the style of the border, and choose other styles and widths for each side. Refer to Figure 32-41.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig41_HTML.jpg
Figure 32-41.

Border style for each side of and image

Should You Add Background Images to Form Elements?

If you add a background image, you can affect other tags, such as those used with the <form> </form> tag. You can find form elements in the Insert Form tab. Refer to Figure 32-42.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig42_HTML.jpg
Figure 32-42.

Alter other tags besides the <div>

These include, but are not limited to, text form fields, button types, and menus/list boxes. All can have a color or a background image added to them. I generally do not add background images (static or animated) to form elements other than maybe a button because with the filling of forms, text is often very detailed and serious work. Having a clashing pattern in an area where a person is trying to fill out text is very distracting and makes the text difficult to read for the viewer. If you do want a color in the background of your field to match your site, stick with solid colors and make sure that the hex code color does not clash with your text.

In Chapter 8 and Chapter 15, I talked about color blindness and how it makes some colors difficult to read. If you are not sure you can always make a screenshot of your form and then bring it into a program like Photoshop and use one of the Color Blindness View ➤ Proof Set Up to see what it looks like and make your CSS adjustments. A similar online example for inspecting color at www.toptal.com/designers/colorfilter .

For now, you focus on the Insert panel’s HTML tab, since most of our work with images and CSS is done here.

CSS3 Borders

Whether you’re working with a static (JPEG, PNG, GIF, SVG) or animated GIF within a <div> tag or as a CSS background, rather than having a solid-colored border, you can add a border image.

This is done by setting the border size, and then style to solid and the color to transparent (no color). In this situation you don’t want to add a Hex color because the border image is that color. With graphics, the border may be quite thick, so padding is important for preventing the text from overlapping. Here is an example of how that could look:
#borderimg1 {
  border: 10px solid transparent;
  padding: 15px;
  -webkit-border-image: url(images/border_test.png) 30 round; /* Safari 3.1-5 */
  -o-border-image: url(images/border_test.png) 30 round; /* Opera 11-12.1 */
  border-image: url(images/border_test.png) 30 round;
}

Note

That some older browsers may not support the property border-image, so you can add the vendor extensions -webkit- for safari and -o- for opera. You must add the same URL to each one. In the preceding code example, I used a PNG image in the URL because I found that a GIF did not stretch accurately for some reason. When working with images in CSS3, always run a test of the script in a separate file before adding to the main file. This saves you a lot of headaches if you test new or experimental settings away from the main design.

The border-image (short form) can be modified further in five main ways.
  • border-image-source: The path to the image to be used as a border.

  • border-image-slice: How to slice the border image.

  • border-image-width: The width of the border image.

  • border-image-outset: The amount by which the border image area extends beyond the border box or overlaps the actual tag.

  • border-image-repeat: Whether the border image should be repeated, rounded or stretched (default).

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

Rounded CSS3 Borders

Since we are on the topic of borders, you can also round the edges of your tags and sematic elements.
div {
    border: 2px solid red;
    padding: 10px;
    border-radius: 25px;
}

For border radius, you can have a background image in your div. This does not appear to work with border-image, so you cannot round your image in the border.

But, you can set your radius to different pixel sizes for each corner, which can give you some very unusual border shapes.
border-top-left-radius: 5px;
border-top-right-radius: 10px;
border-bottom-right-radius: 8px;
border-bottom-left-radius: 6px;
You can further edit the radius using the CSS Designer panel in the Properties tab. Refer to Figure 32-43.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig43_HTML.jpg
Figure 32-43.

Alter the border radius in CSS Designer

By unlinking, you can set each radius differently.

Also, in the Snippets panel (CSS Effects), you find code similar to what is available on W3Schools. Refer to Figure 32-44.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig44_HTML.jpg
Figure 32-44.

The Snippets panel CSS Effects has further resources for editing your image and div elements

Just make sure when you use this code to check it against the current vendor extensions that are being used.

You can see more examples at www.w3schools.com/cssref/css3_pr_border-radius.asp .

Outline CSS2

There is another way to add a fancy border. You can also add a second stroke, called an outline.

Outlines differ from borders in three ways:
  • An outline is a line drawn around elements, outside the border edge to make the element stand out.

  • An outline does not take up space.

  • An outline is generally rectangular; you cannot adjust each side to be different. It does not allow you to adjust its edge radius independently.

The outline property is a shorthand property for setting the following individual outline properties:
  • outline-width: by name(thick) or pixel number

  • outline-style: sets the style, like solid or dotted

  • outline-color

The outline property is specified as one, two, or three values. The order of the values does not matter. The outline is not a part of the element’s dimensions; therefore, the element’s width and height properties do not contain the width of the outline.

You can also add an outline offset. The outline-offset property adds space between an outline and the edge or border of an element. The space between an element and its outline is transparent. Here an example:
div {
     border: 2px solid black;
     outline: 2px solid red;
     outline-offset: 15px;
}

CSS3 box-decoration-break

The box-decoration-break property specifies how the background, padding, border, border-image, box-shadow, margin, and clip-path of an element are applied when the box for the element is fragmented. This is relatively new to CSS3 and is not currently support by Microsoft Edge. It has two settings: slice and clone. You can learn more about it at www.w3schools.com/cssref/css3_pr_box-decoration-break.asp .

Adding CSS3 Filters and Shadows

There are other effects that you can add to your <img> <div> or semantic elements, which don’t have to be added using Photoshop or Illustrator. This makes simple changes easy when you are working with a client on a site.

As you saw in the Snippets panel, there are quite a few CSS3 effects that can be used. The following discusses the CSS that makes this possible.

box-shadow

The box-shadow property attaches one or more shadows to an element.
div {
    border: 1px solid;
    padding: 10px;
    box-shadow: 5px 10px;
}
This is an example of multiple shadows:
box-shadow: 7px 7px red, 10px 10px yellow, 15px 15px green;

The values that you can add include horizontal or vertical offset (h-offset and v-offset); this is required to offset the shadow to the right and bottom. This is the default use of the box-shadow property; negative numbers are set to the left and top.

You can also add a blur radius to make the shadow appear fuzzier. Spread increases the size of the shadow. You can alter the color of the shadow and set an inset to make the shadow inner rather than the default of outset or outer.
box-shadow: 6px 6px 14px 6px #ebebeb;
box-shadow: inset 5px 5px 15px #1abc9c;
You can modify your box shadow further using the CSS Designer panel in the Properties tab. Refer to Figure 32-45.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig45_HTML.jpg
Figure 32-45.

Modify the box shadow using CSS Designer panel’s h-shadow and v-shadow

Box shadows can be used in combination with photos and CSS transform, which you look at in more detail later. For more information, refer to www.w3schools.com/cssref/css3_pr_box-shadow.asp .

text-shadow

You can also add a shadow to text using text-shadow.
div{
text-shadow: 2px 2px 3px #ff0000;
}
It basically has values similar to box-shadow (h-shadow, v-shadow, blur radius, and color), except that they are for adding shadow to text rather than a box. Shadows cannot be inner or inset, only outset. Refer to Figure 32-46.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig46_HTML.jpg
Figure 32-46.

Modify the box shadow using CSS Designer panel

I find text shadow to be extremely useful when building a gallery, and I know the text is over a colorful image as a description or caption. I add a bit of shadow and blur to the text so that it stands out on the images (see gallery.html). As with the box shadow , you can add more than one shadow by separating them with commas.
div{
text-shadow: 2px 2px 3px #ff0000, 0 0 10px #0000ff;
}

CSS Filters

CSS Filters (filter) are similar to the blends that you can create in Photoshop and Illustrator. There are at least 11 filters that you can use on a photograph that are often applied to the <img> tag.
  • None : This is default when no filter is applied

  • blur(px): Applies a blur effect to the image. A larger value creates more blur. If no blur the value is 0.

  • brightness(%) : Adjusts the brightness of the image. 0% makes the image black while 100% (default of 1) is the original image, if you use a higher value over 100%, like 110% this make the image brighter.

  • contrast(%): Adjusts the contrast of the image. 0% makes the image black while 100% (default of 1) is the original image, if you use a higher value over 100% this make the image less contrasted.

  • drop-shadow(h-shadow v-shadow blur spread color) : This filter is very similar to the CSS drop-shadow property; however, be aware that some browsers do not always support the spread values so make sure to compare and test this filter first; for example, filter: drop-shadow(8px 8px 10px gray);.

  • grayscale(%): Converts the image to grayscale or a desaturation. 0% (0) is default and represents the original image. 100%(1) make the image completely gray (used for black and white images); however, negative values are not allowed.

  • hue-rotate(deg) : Applies a hue rotation shift on the image. The value defines the number of degrees around the color circle the image samples be adjusted. 0 deg is default, and represents the original image whereas the maximum value is 360 degrees.

  • invert(%) : Inverts the samples in the image. 0% (0) is default and represents the original image.100%(1) make the image completely inverted, but negative values are not allowed.

  • opacity(%): Sets an opacity level for the image. The opacity-level describes the transparency-level (alpha), where: 0% is completely transparent. 100% (1) is default and represents the original image (no transparency or alpha).

Negative values are not allowed and an alternative to this filter is similar is the opacity property; for example, opacity: 0.5;. In some cases, if text is preset with the background this cause the text to fade as well in that case it is better to use a background-color of RGBa and just adjust the alpha so that the text is not affected.
  • saturate(%): Saturates the image. 0% (0) make the image completely un-saturated. 100%(1) is default and represents the original image. Values over 100%, like 110% provides super-saturated results; however, negative values are not allowed.

  • sepia(%) : Converts the image to sepia tone. 0% (0) is default and represents the original image. 100% (1) make the image completely sepia; however, negative values are not allowed.

  • url() : This is a link to the location of an XML file that specifies an SVG filter and may include an anchor to a specific filter element. You saw SVG filters in Illustrator CC being used; for example, filter: url(svg-url#element-id).

You can use many of these filters either separately or in combination. Further examples can be found in Dreamweaver’s Snippets panel (CSS Effects).
  • Adjust the brightness and contrast of an image

  • Convert an image to grayscale

  • Convert an image to sepia

  • Cross browser opacity

  • Invert the colors of an image

  • Rotate the hue of an image

  • Saturate an image

Be aware the latest browser Microsoft Edge does allow you to view these filters. Internet Explorer does not. There are some JavaScript syntax alternatives you can insert, so make sure to check W3Schools ( www.w3schools.com/cssref/css3_pr_filter.asp ) if this is a concern.

Also make sure to add the correct vendor extensions for those browsers that require it; for example, -webkit-; otherwise, it would be best to do the blending in Photoshop or Illustrator so that your audience sees the correct image.

Image Masking in CSS3?

Another filter that in the future we might be able to look forward to is Mask this is still in the experimental stages, but allows you to mask an element. In addition, you may be able to work with gradients with the masking.

For more information, visit https://developer.mozilla.org/en-US/docs/Web/CSS/mask-image .

Adding Custom Images to Bullets

If you need bulleted lists for your site, you can add them via the Insert panel in the HTML tab as you did with the <div>, <img>, and other semantic elements. Refer to Figure 32-47.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig47_HTML.jpg
Figure 32-47.

Add list item bullets

As a review, unorder lists <ul> use bullets each part of the list is a list item or <li>. There are about 3 default sets (disk, circle, square) and you have the option of setting the list to none, if you don’t want bullet which can be useful if you are creating some form of navigation.

An ordered list <ol> uses list items <li> as well but rather than being the same bullet or bullet set they are a set of numbers (1,2,3) letters (a,b,c, or A,B,C) or roman numerals (i,ii,iii or I, II, III). These can be added via an attribute of type being added to the tag; for example type="A". For more information on lists, refer to www.w3schools.com/html/html_lists.asp .

However, what if you want custom bullets from an image that is static GIF or PNG, or a GIF animation?

This can be altered in two ways; one is via the content property and using an unorder list.
ul {
    list-style: none; /* Remove HTML bullets */
    padding: 0;
    margin: 0;
}
li {
    padding-left: 16px;
}
li:before {
    content: "0"; /* Insert content that looks like bullets */
    padding-right: 8px;
    color: blue; /* Or a color you prefer */
}

Earlier you looked at pseudo class and pseudo elements. They can be used to target certain elements or the actions of a certain element such as hover. However, you can also target where a custom bullet start and stop. The first thing to do is remove the original default bullets of the unordered list, list-style: none;. Then in the <li>, add the new bullet using the :before content property (pseudo element) before the words of each bullet. The :after pseudo element adds them after each word. If you just plan to use symbols, W3Schools has an entire entity reference chart of choices at www.w3schools.com/cssref/css_entities.asp .

If you wanted an asterisk, you would write
content: " \ 002A";

This creates an asterisk bullet. There are many clip-art symbols to choose from in the list. And you can color to a separate color from the text.

However, our main goal here is to add an image not a symbol. To do this, you must make a small symbol 32×32 pixels or less with a transparent background; it can be a GIF or PNG.

Rather than using content, you can use the property list-style.
ul {
     list-style: square url(images/shape.gif);
}

This sets the list-style-type, list-style-position, list-style-image.

Now the type of list in this case does not really matter what style it is because you are overriding it with the new image.
ul {list-style-type: square;}
The position can either be on the outside or inside. You do not need to write outside as this is the default.
list-style-position: inside;
The image is the URL link. This link should match the location of where your image is located.
list-style-image: url(images/shape.gif);
Refer to Figure 32-48 to see how this appears in the CSS Designer panel in the Properties tab.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig48_HTML.jpg
Figure 32-48.

Add an image or GIF animation to a replace a list item bullet using CSS and the CSS Designer panel

As with the content property, you can use pseudo elements (:before and :after) to target placement but you could go even further using [target attributes] and your content properties, as you look at in Chapter 37, for when you need to have thumbnail reference links for images that don’t display.

Creating CSS Animation Transitions and Transforms

So far with CSS, you have looked at some ways to enhance your images and tags using CSS. You also saw that many of these examples are stored in Dreamweaver’s Snippets panel, and you can add your own examples to the Snippet panel library. As you explore the Snippets panel, you may come across a few more CSS3 items that you have never used that relate to animation.

Refer to the folders CSS Animations, Transitions, and CSS Effects (Rotate and Element 3D Transform). Refer to Figure 32-49.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig49_HTML.jpg
Figure 32-49.

Examples of animation and transitions can be found in the Snippets panel

Before CSS3, you had to rely on scripts like JavaScript or ActionScript Flash to create animations for the web. While Adobe Animate CC is a wonderful program for creating complex animations, sometimes you just want to create a simple movement of a <div> tag with a background image or color transition. These transitions allow you to alter property values with ease from one value to another. As you can see, Dreamweaver offers several good examples for you to test. And if you require more, you can find quite a few at W3Schools, such as the following:

Let’s look at the main properties of each CSS type of CSS.

Note

While the examples in the Snippets panel do work, I have noticed that in some older version of Dreamweaver CC 2017 the vendor prefixes for the Opera browser show up as a zero rather than a lowercase o; for example, -0-animation should be -o-animation. I did not encounter this in the CC 2018 version, so from what I can see, the Adobe designers have corrected this error in the latest version. Also note that in most cases of backward compatibility, the vendor prefixes that are currently used are -moz- or -webkit-. The most modern browsers, however, don’t require this extension in the properties. Nevertheless, this is useful information to keep in mind depending on what audience you are design for or if you are working with CSS that a client designed a few years ago.

CSS3 Animations

As you saw in Photoshop CC and Animate CC, animations are made up of keyframes and properties that control the direction and duration of the moving object. The same is true with CSS3 in the form of code.

An animation in CSS3 lets an element such as a <div> tag gradually change from one style to another. This can be done using the selectors and properties of To - From or by percentage and their respective values. You can change as many CSS properties as you want for as many times as you want.

To use CSS animation, you must first specify some keyframes for the animation. Other properties can be applied to the <div> tag, such as width or height, and these can be altered by the animation properties and keyframe that are linked to it. To get an animation to work, you must bind the animation to an element.
div {
    width: 100px;
    height: 100px;
    background-color: blue;
    -webkit-animation-name: colorchange; /* Safari 4.0 - 8.0 */
    -webkit-animation-duration: 4s; /* Safari 4.0 - 8.0 */
    animation-name: colorchange;
animation-duration: 4s;
animation-delay:2s;
}
/* Safari 4.0 - 8.0 */
@-webkit-keyframes colorchange {
    from {background-color: blue;}
    to {background-color: yellow;}
}
/* Standard syntax */
@keyframes colorchange {
    from {background-color: blue;}
    to {background-color: yellow;}
}
Keyframes hold the styles the element has at certain times. The following are the main properties.
  • @keyframes : Specifies the animation code. Animation happens when the CSS styles change gradually from one to another; during this time you can the set of CSS styles many times. Properties can be found within the brackets {} of the key frame. Examples are: from{starting property: value;), to{ending property: value;} or percent, which lets you be more accurate in your animation changes.

@keyframes colorchange {
     0%   {background-color: red;}
     25%  {background-color: yellow;}
     50%  {background-color: orange;}
     100% {background-color: purple;}
}
Movement can also be added within the brackets and you could return to your starting point.
@keyframes colorchange {
     0%   {background-color:red; left:0px; top:0px;}
     25%  {background-color:yellow; left:100px; top:0px;}
     50%  {background-color:blue; left:100px; top:100px;}
     75%  {background-color:orange; left:0px; top:100px;}
     100% {background-color:purple; left:0px; top:0px;}
}
Here you can see points of change at 25% then again at 50% and the final ending color at 100%.
  • animation: A shorthand property for setting all the animation properties.

  • animation-delay : Specifies a delay for the start of an animation if you don’t want it to start right away such as animation-delay:2s; which means 2 seconds of delay. Then the animation-duration can begin. Negative duration can be used as well such as animation-delay:-2s; This moves the animation 2 seconds into the animation duration or as if it had already been playing for 2 seconds. It can also be defined in milli-seconds (ms).

  • animation-direction : Specifies whether an animation should be played forward, backward, or in alternate cycles. The default is animation-direction: normal; This runs the animation in the original order set up. A reverse setting plays the animation backward. Other options include alternate (plays forward then backward) and alternate-reverse (plays backward then forward). In alternate and alternate-reverse, you need to set the animation-iteration-count: 2; otherwise, it does not play both the forward and reverse movements, only one way.

  • animation-duration : Specifies the time that an animation should take to complete one cycle; for example, 4s means 4 seconds. The default is 0 seconds (0s) if this property is not added. It can also be defined in milliseconds (ms).

  • animation-fill-mode : Specifies a style for the element when the animation is not playing. It can be before it starts, after it ends, or both times; for example, animation-fill-mode: both;.

  • none : This is the default value. Animation does not apply any styles to the element before or after it is executing.

  • forward : The <div> element retains the style values set by the last keyframe (depends on animation-direction and animation-iteration-count).

  • backward : The <div> element gets the style values set by the first keyframe (depends on animation-direction) and retains this during the animation-delay period.

  • both : The animation follows the rules for forward and backward, extending the animation properties in both directions or times in the keyframe. (from and to).

  • animation-iteration-count : Specifies the number of times an animation should be played. You can play as many times as you like. For example, animation-iteration-count:3; means three times, but if you wanted an infinite loop, you could set it to animation-iteration-count: infinite;.

  • animation-name : Specifies the name of the @keyframes animation. This is the name that is tied to the animation; for example, see how colorchange is referenced as the animation.

div {
   /*Some CSS properties*/
    animation-name: colorchange;
}
@keyframes colorchange {
    from {background-color: blue;}
    to {background-color: yellow;}
}
  • animation-play-state : Specifies whether the animation is running (default) or paused; for example, animation-play-state: paused;.

  • animation-timing-function : Specifies the speed curve of the animation. This effects the movements as to whether they speed up or slow down within the animation, this can make movements fluid and smooth. You saw examples of this in Animate CC in Part 4 and the same concept can be applied to animation of CSS3.

  • ease : An animation starts slowly start, speeds up, and then ends slowly (this is default setting).

  • linear : An animation with the same speed from start to end.

  • ease-in : An animation with a slow start.

  • ease-out : An animation with a slow end.

  • ease-in-out : An animation with a slow start and end.

  • step-start : Equivalent to steps(1, start).

  • step-end : Equivalent to steps(1, end).

  • steps(int,start|end) : A stepping function with two parameters. The first parameter specifies the number of intervals in the function. It must be a positive integer (greater than 0). The second parameter is optional; the value "start" or "end", and specifies the point at which the change of values occurs within the interval. If the second parameter is omitted, it is given the value "end".

  • cubic-bezier(n,n,n,n) : Lets you define your own values in a cubic-bezier function. The values are numeric values from 0 to 1; for example,

#div1 {animation-timing-function: cubic-bezier(0,0,1,1);}
#div2 {animation-timing-function: cubic-bezier(0.25,0.42,0.25,1);}
Animation can be written in shorthand.
div {
     animation: colorchange 5s linear 2s infinite alternate;
}
@keyframes colorchange {
     0%   {background-color:red; left:0px; top:0px;}
     25%  {background-color:yellow; left:100px; top:0px;}
     50%  {background-color:blue; left:100px; top:100px;}
     75%  {background-color:orange; left:0px; top:100px;}
     100% {background-color:purple; left:0px; top:0px;}
}
Also, like all other CSS, you can apply it to an ID or to a class (.easeinAnimObj) within a tag. In Dreamweaver, the Snippets panel gives you hints when you insert the snippet as to what to name the class so that your animation animates correctly.
<div class="easeinAnimObj">
/*
Define this in your CSS
.easeAnimation = Replace it by the name you want to give your animation
.easeAnimObj = Assign this class to elements to which you intend to apply the animation
*/

If you find additional animations that you like, save them in a file as a backup and add them to the Snippets panel for later use.

CSS Transitions and Transitions Panel

Transitions are in the Snippets panel. Refer to Figure 32-57. Since they are found in the same folder, are they the same as CSS animations?

Transitions allow you to change property values smoothly (from one value to another) over a given duration. For example, when you hover over a <div> tag element, the CSS of transition effect causes the element to grow or shrink.

To create a transition effect, you must specify at least two things:
  • the CSS property that you want to add an effect to

  • the duration or time of the effect

If no duration is specified, the transition does not work because it is at zero; for example,
div {
    width: 100px;
    height: 100px;
    background: red;
    -webkit-transition: width 2s; /* Safari */
     transition: width 2s;
}
Then add a :hover pseudo class.
div:hover {
     width: 300px;
}

This the element changes on the hover state. Its width grows to 300px;. You could also add a height and even a color change for the hover. When the mouse is removed, the shape gradually changes back to its original size.

Like animation, many of the properties are similar except that they have the word transition before instead of animation. For example, animation-delay is now transition-delay.

The following are the transition properties.
  • transition : A shorthand property for setting the four transition properties into a single property; for example,

div {
     transition: width 2s linear 1s;
}
  • transition-delay : Specifies a delay in seconds (s) or milliseconds(ms) for the transition effect before starting; for example, transition-delay: 1s;. The default value is 0s.

  • transition-duration : Specifies the number of many or milliseconds a transition effect takes to complete.

  • transition-property : Specifies the name of the CSS property the transition effect is for; for example, transition-property: width;. This target the width. If you want to target the height, change it to transition-property: height;.

  • transition-timing-function : Specifies the speed curve of the transition effect; this is like the animation properties.

  • ease : A transition effect with a slow start, then speeds up, and then ends slowly (default setting).

  • linear : A transition effect with the same speed from start to end.

  • ease-in : A transition effect with a slow start.

  • ease-out : A transition effect with a slow end.

  • ease-in-out : A transition effect with a slow start and end.

  • step-start : Equivalent to steps(1, start).

  • step-end : Equivalent to steps(1, end).

  • steps(int,start|end) : This is a stepping function with two parameters. The first parameter specifies the number of intervals in the function. It must be a positive integer (greater than 0). The second parameter, which is optional, is either the value “start” or “end”, and specifies the point at which the change of values occurs within the interval. If the second parameter is omitted, it is given the value “end”.

  • cubic-bezier(n,n,n,n) : This lets you define your own values in a cubic-bezier function. The values are from 0 to 1; for example,

#div1 {transition-timing-function: cubic-bezier(0,0,1,1;}
#div2 {transition-timing-function: cubic-bezier(0.25,0.1,0.25,1);}
Transition can also be combined with transformation. You look at 2D and 3D transforms in a moment. You can see it in this example:
div {
    width: 100px;
    height: 100px;
    background: red;
    -webkit-transition: width 2s, height 2s, -webkit-transform 2s; /* Safari */
    transition: width 2s, height 2s, transform 2s;
}
div:hover {
    width: 300px;
    height: 300px;
    -webkit-transform: rotate(180deg); /* Safari */
    transform: rotate(180deg);
}
Also, like all other CSS, you can apply it to an ID or to a class (.linearTransition) within a tag. In Dreamweaver, the Snippets panel gives you hints when you insert the Snippet as to what to name the class so that your transition animate correctly.
<div class=”.linearTransition”>
/*
  Define this in your CSS
  .linearTransition = Replace it by the name you want to give your transition
*/

You would also change your :hover state to something like .linearTransition:hover or whatever name in the CSS.

Unlike the CSS3 animation, Dreamweaver CC has a special panel for transitions called the CSS Transition panel.

CSS Transition Panel

If your website’s CSS currently contains no transition examples that are linked to tag, ID, or class, the CSS Transition panel appears blank. However, if you have already created a CSS Transition panel, it displays a basic preview of the available transitions. Refer to Figure 32-50.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig50_HTML.jpg
Figure 32-50.

The CSS Transitions panel

To add or apply a new transition to an element, make sure that you select the <div> tag that you want to apply the new transition to, click the plus (+) icon, to remove the code select the transition in the panel and click the minus (–) icon. To edit, select the transition in the panel and then click the Pencil icon. You can also use the submenu to access the same icons found on the panel or by right-clicking the transition in the panel.

Note

For this transition to be viewable in your browser, you need to add the class to a <div> tag either before or after you create the transition with a starting width, height, and background color or background image; otherwise, the animation may not be visible. You can use the CSS Designer panel or enter the information in Code view in your external CSS file as seen in the following code example.

Example:
.color-alter{
width: 50px;
    height: 30px;
    background-color: aqua;
/*transition and its vendor prefixes be added below this once you enter your information in the dialog box*/
}
In the HTML document, this is how the class for the transition should be added.
<div class="color-alter"> </div>
If you are creating a new transition rather than entering it yourself in your CSS file, you can use the New Transition dialog box to help set it up. Click the plus (+) icon to enter the dialog box. Refer to Figure 32-51.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig51_HTML.jpg
Figure 32-51.

The New Transition dialog box

  • Target Rule : This is a current class or rule that you have created and can select from the drop-down menu. If there is no current target, then you can enter your own. In this case I chose the class “.color-alter”. Refer to Figure 32-52.

../images/466782_1_En_32_Chapter/466782_1_En_32_Fig52_HTML.jpg
Figure 32-52.

Set a Target rule

  • Transition On : Allows the user to choose the state the transition is triggered on. There are several pseudo classes to choose from. Active are used with a link like an a:link. Checked, disabled, enabled, focus, and indeterminate are used with various <input> form elements. Hover is used when hovering over a <div> tag element, but it might be used for a link as you would :target with an anchor; for example, #news:target. This area does not allow you to apply the same transition in the same class again. For example, if you already used the :hover pseudo class, when you try to apply it again, it is gone from the list. Only a new class with a different name that never used :hover allows this option to be available again. Refer to Figure 32-53.

../images/466782_1_En_32_Chapter/466782_1_En_32_Fig53_HTML.jpg
Figure 32-53.

Transition states once used are not available in the list for the current class

From the next drop-down menu, you can choose to use the same transition for all properties that you enter next or a different transition for each property. This depends on the complexity of the transition you plan. In Edit mode, it is the second option when you click the Pencil icon. Refer to Figure 32-54.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig54_HTML.jpg
Figure 32-54.

Alter how you want the transition to be applied

You can set the transition duration (either in seconds or milliseconds). You can set the transition delay and the timing function. This sets the speed for the ease in and out. For a detailed list of what each function means, refers to the transition-timing-function section earlier in this chapter on the topic of CC transitions. Refer to Figure 32-55.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig55_HTML.jpg
Figure 32-55.

Set duration, delay, and timing function

Next, you look at the properties that affect the end value. Refer to Figure 32-56.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig56_HTML.jpg
Figure 32-56.

Set the end value properties

You can add one or more transition-properties to the list by clicking the plus (+) icon and choosing one at a time from the list. This would be the equivalent of writing height; or background color. Minus (–) removes properties. Refer to Figure 32-57.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig57_HTML.jpg
Figure 32-57.

Properties added to the list

Depending on what property value you choose, the end value may be different. In width or height, it could be auto or 100px, or whatever setting you are using, such as em or %. Refer to Figure 32-58.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig58_HTML.jpg
Figure 32-58.

Set the end value

Once the end value is entered, press Enter or Return on your keyboard to confirm it.

Lastly, you want to determine where the CSS transition is placed: in this document or a new style sheet file. Refer to Figure 32-59.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig59_HTML.jpg
Figure 32-59.

Determine where you want the CSS to appear internal or external

If you are experimenting, I recommend keeping your transition in a new style sheet file. After you have perfected it, copy it into your final CSS file with your other CSS.

You may want to keep all your CSS transitions in a separate CSS file to keep them organized and separate from other CSS; the choice is up to you. Just make sure that the external file links correctly to your document.

It is much easier to type or select these options in Dreamweaver rather than type everything by hand in Code view. When you are done, click the Create Transition button. If you receive a warning, it may be because you did not add something to a text field, so follow the instructions and then click the button again. Refer to Figure 32-60.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig60_HTML.jpg
Figure 32-60.

Click the Create Transition button to confirm the transition settings

Once you exit the dialog box, Dreamweaver generates your CSS transition in (short form) based on the setting you provided in the current document or in a new CSS file.

To remove a transition from the panel, when selected, use the minus (–) icon. You have options for what you want to remove. You can remove the whole transition or the class for the <div> tags or elements. Refer to Figure 32-61.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig61_HTML.jpg
Figure 32-61.

Remove Transition dialog box

When a rule like :hover is selected in the Transitions panel, you can then use the Pencil icon to edit it further. The Edit transition dialog box is very similar to the New Transition dialog box, but its default setting is “Use a different transition for each property” if there are multiple properties. Refer to Figure 32-62.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig62_HTML.jpg
Figure 32-62.

Edit Transition dialog box

When done editing, click Save Transitions to save the changes. When you switch to Live view, the new content should be functioning automatically.

Note

If you noticed that you applied the class to the wrong tag, for instance <body>, you can delete it in Code view. Then select the correct tag, and using the Properties panel, apply the class to the correct <div> tag.

The final code might look like this:
.color-alter{
    width: 50px;
    height: 30px;
    background-color: aqua;
    -webkit-transition: all 2s linear 2s;
    -o-transition: all 2s linear 2s;
    transition: all 2s linear 2s;
}
.color-alter:hover {
    height: 200px;
background-color:#FF0004;
}

Next, you look at the third type of CSS3 animation: transforms.

CSS Transforms 2D and 3D: It’s All About Perspective

Transforms let us do some amazing things with <div> and semantic elements. In combination with CSS animations (from, to) or CSS transitions that use the :hover pseudo class, you can translate, rotate, scale, and skew elements in two dimensions (x and y) or in three dimensions (x, y and z). The <div> or element changes shape, size, and position. Unfortunately, there are not a lot of examples available in the Snippets panel other than Reverse Text Using CSS and Rotate and Element (3D transform).

You can find more examples on the W3Schools website at www.w3schools.com/css/css3_2dtransforms.asp and www.w3schools.com/css/css3_3dtransforms.asp .

Because transforms are newer, they rely on vendor prefixes for older browsers, such as -webkit-, -ms-, or -o-. Always check which prefixes should be added for any new CSS3 elements to reach the largest audience; for example, as -ms-transform: translate(50px, 100px); for Microsoft Edge users. At some point, when all the modern browsers agree, you just have to write transform: translate(50px, 100px); without the vendor prefix.

To begin a transform, you need to have a starting width and height for your class that is attached to the <div> tag. Then below that, add the transform properties; for example,
.shape {
    width: 200px;
    height: 100px;
    background-color: yellow;
   /*transforms below*/
    -ms-transform: scale(0.5,0.5); /* IE 9 */
    -webkit-transform: scale(0.5,0.5); /* Safari */
    transform: scale(0.5,0.5); /* Standard syntax */
}

2D Transform

Let’s look at the properties of the 2D transform.
  • transform : Applies a 2D or 3D transformation to an element or <div>.

  • transform-origin(x%,y%) : Allows you to change the position on transformed elements. It must be used with the transform property. You can use negative and positive presents or values, 0% is the default; for example,

div {
    transform: rotate(45deg);
     transform-origin: 20% 40%;
}

Other values are x (left, center, right and length) and y (top, center, bottom and length).

Each property can then have functions applied to it.
  • matrix(n,n,n,n,n,n): A 2D transformation, using a matrix of six values, combines the 2D transform methods into one; for example, matrix(scaleX(),skewY(),skewX(),scaleY(),translateX(),translateY())looks something like transform: matrix(1, –0.3, 0, 1, 0, 0);. Note that rotation appears as a separate property.

  • translate(x,y) : A 2D translation, moving the element from its current position along the x axis and the y axis; for example, transform: translate(20px, 100px);. Moves 20 pixels right and 100 pixels down.

  • translateX(n) : A 2D translation moving the element along the x axis.

  • translateY(n) : A 2D translation moving the element along the y axis.

  • scale(x,y) : A 2D scale transformation changing the elements width and height or making the <div> larger or smaller; for example, transform: scale(3, 4);. This would make the <div> three times the original width and four times the original height. To decrease a <div> to a quarter of its size you could write, transform: scale(0.25, 0.25);.

  • scaleX(n) : A 2D scale transformation changing the element’s width.

  • scaleY(n) : A 2D scale transformation changing the element’s height.

  • rotate(angle) : A 2D rotation; the angle is specified in the parameter as clockwise or counter-clockwise; for example, transform: rotate(20deg);. If you change to –20deg, this rotates it in a counter-clockwise direction.

  • skew(x-angle,y-angle) : A 2D skew transformation along the x axis and the y axis; for example, transform: skew(30deg, 10deg);. When a second parameter is not written, it is assumed to be 0 degrees. A negative degree skew the X or Y – axis of the <div> in the opposite direction.

  • skewX(angle) : A 2D skew transformation along the x axis.

  • skewY(angle) : A 2D skew transformation along the y axis.

You can add any of these functions in one transform property, such as
transform: rotate(20deg) scale(3,4);
When a transform is added to a CSS Transition panel and you select edit or new, it is added as another property that appears in the hover area of the class. Refer to Figure 32-63.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig63_HTML.jpg
Figure 32-63.

The Transition dialog box

The :hover pseudo class in Code view may look like this:
.color-alter:hover {
    height: 200px;
        background-color:#FF0004;
        transform: matrix(1, -0.3, 0, 1, 0, 0);
        transform: rotate(20deg);
}

3D Transform

Much of the same properties work with 3D transforms, except you are adding the z axis, or a third dimension. CSS3 makes the transform appear that it has changed in 3D space, and if you apply it to a transition, it makes the <div> element appear as if it is moving in a 3D way. 3D transform works with all modern browsers, but you may need to add vendor prefixes to the properties.

Let’s look at the properties of the 3D transform.
  • transform : Applies a 2D or 3D transformation to an element or <div>.

  • transform-origin(x%,y%,z) : Allows you to change the position on transformed elements. It must be used with the transform property. You can use negative and positive presents or values, 0% is the default; for example,

div {
    transform: rotate(45deg);
     transform-origin: 20% 40% 0;
}
Other values are x (left, center, right, and length), and y (top, center, bottom and length); z is just length.
  • transform-style : The way nested elements are rendered in 3D space. This property must be with the transform to work correctly. The two main options are flat (default: child elements do not preserve the 3D position but are against the parent element) and preserve-3d(child elements preserve 3D position in their own space); for example,

div {
     transform: rotateY(60deg);
     transform-style: preserve-3d;
}
  • perspective : Specifies the perspective on how 3D elements are viewed, and alters it. When defining the perspective property for an element, the child elements get the perspective view, not the parent element. For example, add perspective: 150px; :

.class1 {
    position: relative;
    height: 150px;
    width: 150px;
    margin: 50px;
    padding: 10px;
    border: 1px solid black;
    -webkit-perspective: 150px; /* Safari 4-8  */
    perspective: 150px;
}
.class2 {
    padding: 50px;
    position: absolute;
    border: 1px solid black;
    background-color: red;
    -webkit-transform: rotateX(45deg); /* Safari 3-8  */
    transform: rotateX(45deg);
}
Then apply it to the <div> tags.
<div class="class1">
  <div class="class2">WELCOME</div>
</div>

It is the inner class (class2) or child that receives the perspective and not (class1), which in this case is the parent.

The perspective property only affects 3D transformed elements. You can use this property with the perspective-origin property, which allows you to change the bottom position of 3D elements. Length (pixels) and none are the two values.
  • perspective-origin(x%,y%) : The bottom position of 3D elements for the x and y axis. The child elements get the positioning, not the parent element. This element must be used with the perspective property and can only be used on 3D transform elements; for example,

perspective: 150px;
perspective-origin: 10% 10%;
Other values are x (left, center, right and length) and y (top, center, bottom and length). In both cases, 50% is the default.
  • backface-visibility : Defines whether or not an element should be visible when not facing the screen. This is an interesting effect that allow you to rotate or reverse an image. You can also determine whether the back be visible or hidden.

This property is useful when an element is rotated. An example is playing cards that flip. Each side has an image and uses functions such as rotate or rotate3d.
#div1 {
     backface-visibility: hidden;
}
#div2 {
     backface-visibility: visible;
}
3D transform has several functions that are used with the transform property, some of which are similar, but now have the z axis.
  • matrix3d(n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n) : Defines a 3D transformation, using a 4x4 matrix of 16 values. This one requires a bit of experimentation to figure out what numbers relate to which functions, but it essentially follows the same order as the 2D transform except that now you have added a z axis. I recommend using the separate functions if you are not sure what each one is for.

  • translate3d(x,y,z) : A 3D translation or movement of the element from its current position along the x, y and z axis; for example, transform: translate3d(10px, 0, 100px). Positive values move down, right and forward while negative values move up, left and backward or smaller;

  • translateX(x) : A 3D translation using only the value for the x axis.

  • translateY(y) : A 3D translation using only the value for the y axis

  • translateZ(z) : A 3D translation using only the value for the z axis (does not allow a percentage value.)

  • scale3d(x,y,z) : A 3D scale transformation; for example, transform: scale3d(2, 0.7, 0.2);. One would be the default, but 2 would be twice the size and 0.5 would be equivalent to 50% of the size of any axis. Positive and negative numbers can be used to move the element in a different axis.

  • scaleX(x) : A 3D scale transformation giving a value for the x axis.

  • scaleY(y) : A 3D scale transformation giving a value for the y axis.

  • scaleZ(z): A 3D scale transformation giving a value for the z axis.

  • rotate3d(x,y,z,angle) : A 3D rotation. The numbers of x, y, and z could be a coordinate of the vector shape describing an axis of rotation. Positive numbers rotate clockwise. Negative numbers are also used of you are rotating counter-clockwise; for example, transform: rotate3d(0, 1, 0, 60deg);.

  • rotateX(angle): A 3D rotation along the x axis.

  • rotateY(angle): A 3D rotation along the y axis.

  • rotateZ(angle): A 3D rotation along the z axis.

  • perspective(n): Defines a perspective view for a 3D transformed element or elements depth. Zero or lower value give a pronounced perspective while higher value creates a foreshortening; for example,

perspective(500px);
You can add any of these functions in one transform property, such as
transform: rotate3d(0, 1, 0, 60deg) scale(3,4,2);
3D transforms can be edited in the CSS Transitions panel. Refer to Figure 32-64.
../images/466782_1_En_32_Chapter/466782_1_En_32_Fig64_HTML.jpg
Figure 32-64.

The Transition dialog box

Summary

In this chapter, you looked at how CSS can affect tags and elements. You looked at various CSS3 properties and learned how they can be edited in various panels in Dreamweaver. You also looked at animations, transitions and transforms.

In the next chapter, you look at how to enhance your site further for mobile web design.