Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Web Design & Development

  • Print
  • + Share This
This chapter is from the book

Using layers

You can use layers to divide your page into rectangles that can be formatted and positioned individually, much as you can with a traditional page layout application like Adobe InDesign. Layers can contain any HTML element that a page can contain, such as an image or simple HTML text with formatting. You use the Layer tool and the Layers palette to add and manage multiple layers on the page.

Adding layers to an HTML page

For this document you will create a layout similar to the table lesson, but use layers.

Make sure that the student.site window is still open. If it is not, choose File > Open Recent Items and locate the student.site file, or choose File > Open and browse to locate the saved student.site file in Lesson03 > student folder.

  1. Choose File > Open. Browse to locate the file named layout_finish.html in the Lesson03 folder. Press Open. The finished layer file appears.

    This is the page you will create using layers. You will learn how to create, name, and arrange stacking order of the layers along with other layer features.

  2. Choose to leave this file open as a reference, or choose File > Close.
  3. Choose File > Open and browse to locate the file named layout_start.html in the Lesson03 folder. The start page appears.
  4. Choose File > Save As. Keep the name the same and click on the Site Folder (sitefolder.jpg) and select Root (Windows) or Root folder (Mac Os). Click Save.
  5. Begin this page by selecting the Layer object (layerobject.jpg) from the Basic section of the Objects palette.
  6. Click and drag the Layer object to the layer_start.html page.

    A layer appears in the upper left of the page.

  7. If the Inspector is not visible, choose Window > Inspector. While the layer is selected, the Inspector is a Layer Inspector.
  8. Change the name from layer1 to logo in the Name text field; press Return. This will help you identify the layer later.
  9. Drag the right center handle to the right to make the layer approximately 600 pixels wide. As you drag, observe the value in the Width text field in the Main toolbar. You can also type the value of 600 into the Width text field. Type 62 in the Height text field.

    Use the Main toolbar for accurate layer coordinates and size controls.

Inserting objects into the layer

Now you will insert an image and text into the layer.

  1. Using the Standard Editing tool (editing.jpg), click to insert the blinking cursor inside the layer.
  2. Double-click on the Image Object in the Basic section of the Objects palette. The image Object appears in the layer.
  3. Using the Image inspector, click on the Browse button (browsebutton.jpg) to the right of (EmptyReference!) When the Open dialog window appears, navigate to locate the image file named virtechu_logo.gif in the web-content folder of the student folder inside of Lesson03. Choose Open. The logo appears inside the layer.
  4. Using the Standard Editing tool, click once on the VirtechU logo image. Use the Alignment drop-down menu in the Basic tab of the Image Inspector to change the alignment to Middle. Alignment determines the position of the text that follows the image.
  5. Click to the right of the logo; a large blinking cursor appears. Press the spacebar once and type The place to learn technical skills.
  6. Position the cursor over the edge of the layer. When the hand icon (handicon.jpg) appears, click to select the layer.

    Just as with table cells, you can apply a class style to the contents of a layer.

  7. Choose Type > CSS Style for <div> select headline. The text is changed to red.

Aligning and distributing layers

In this next section, you will add the imagery in three separate layers which you will then align and distribute.

  1. Click and drag a Layer object from the Basic section of the Objects palette to your HTML page. Make sure that you do not drag the new layer into the existing layer.
  2. Reposition the new layer by positioning the cursor over the edge of the layer. When a hand icon (handicon.jpg) appears, click and drag to move the layer beneath the logo layer. Use the grid that appears to align the left sides of the two layers. Type 100 in the Vertical Position text field of the Main toolbar.
  3. Select Edit > Duplicate to duplicate this layer and put a copy directly on top of the existing layer.
  4. Choose Edit > Duplicate again. This will provide you with three layers, all positioned on top of one another.
  5. Using the Object Selection tool (selectiontool.jpg), click on the topmost layer and drag it to the right of the page. Then select the next layer and position it in between the left and right layer. Exact positioning is not important.
  6. Using the Object Selection tool, select the left layer and type laptop in the Name text field of the Layer Inspector.
  7. Select the center layer. Type female into the Name text field in the Layer inspector.
  8. Select the right layer. Type group into the Name text field.
  9. Using the Object Selection tool, select the first layer, now named laptop. Hold down the Shift key and click on the layer named female and the last layer named group.

    All three layers are selected.

  10. Choose Window > Align. The Align palette becomes visible. Select Horiz. align centers (Windows) or Horiz. distribute center (Mac OS) from the Distribute Objects section of the Align palette. Then select the Align Tops button under Align Objects.
  11. Choose File > Save. Leave the file open for the next part of this lesson.

Adding imagery and text

  1. Position the student.site window so that you can see it at the same time as the layout_start.html file.
  2. Click on image_1.jpg and drag it into the leftmost layer.
  3. Drag image_2 into the middle layer.
  4. Drag image_3 into the rightmost layer.

    You will now add another layer that will be used for text.

  5. Make sure that the Basic section of the Objects palette is visible. Select the Layer object (layerobject.jpg) and drag it to an empty spot on your layout_start.html page, making sure that you do not drag the new layer into an existing layer. It is positioned in the upper left of the page.
  6. After placing the Layer object, cross your cursor over the side and click when you see the hand icon (handicon.jpg). This selects the layer. Use the position and size text fields in the Main toolbar for an accurate-sized layer. Enter 18 for the Horizontal Position and 240 for the Vertical Position. Enter 475 in the Width text field and 150 in the Height. Press Enter.
  7. With the layer still active, type text into the Name text field in the Layer tab of the Layer Inspector. Press Enter.
  8. Choose File > Open. When the Open dialog window appears, browse to locate the file named student.txt in the Lesson03 folder, and choose Open.
  9. Select the paragraph text located under the dashed line and choose Edit > Copy. Then choose File > Close.
  10. Return to the layer_start.html file, and using the Standard Editing tool (editing.jpg), click inside the new text layer you created. Then choose Edit > Paste.
  11. Choose Type > CSS DIV select gray_text. The text is changed to gray.
  12. Choose File > Save. Leave the file open.

Organizing layers

In this next section you will create a new layer with a colored background. Since layers’ default stacking order is such that this layer will cover the existing layers, you will learn how to change the stacking order.

  1. Select the Layer object (layerobject.jpg) from the Basic section of the Objects palette and drag it to an empty spot on your layout_start.html page, making sure that you do not drag the new layer into an existing layer. The new layer is positioned in the upper left of the page.
  2. After placing the layer object, select it and use the position and size text fields in the Main toolbar. Enter -5 for the Horizontal Position and -5 for the Vertical Position. Enter 675 in the Width text field and 150 in the Height. Press Enter.
  3. With the layer still active, type background into the Name text field in the Layer tab of the Layer Inspector. Press Enter.
  4. Click on the Background tab of the Layer Inspector and double-click on the color box. Enter 9F9F9F into the hexadecimal text field. Press the Tab key and then press OK.

    The background of the new layer is now gray.

    The newly created layer is covering the existing layers. To change this, you need to understand the concept of layer arrangement using Z-index.

Changing the Z-index

  1. Choose Window > Layers to make the Layers palette visible.
  2. In the Layers palette, select the background layer.
  3. With the background layer selected, type 0 in the Z-index text field located in the Layer tab of the Layer Inspector. Press Enter.

    Changing just this layer will not affect where it appears in the stacking order until we also change the other layers’ Z-index values. To make selecting the layers easier, you will use the Layers palette.

Using the Layers palette

You can use the Layers palette (Window > Layers) to quickly select multiple layers for alignment and grouping. You can also use the Layers palette to temporarily lock, hide, or show a layer as you work. (Unlike similar settings in the Layer Inspector, lock, hide, and show settings in the Layers palette do not affect the display of layers in the browser.)

  1. Click on the layer “logo” in the Layers palette. This selects the layer and allows you to make changes in the Layer Inspector. In the Z-index text field, type 5, then press Return or Enter. This brings the logo layer in front of the background layer.
  2. Select the layer named laptop and type 5 into the Z-index text field.
  3. Individually select the layers female and group, and type 5 into the Z-index field. Press Return or Enter.

    With the layers’ Z-index assigned to higher numbers, they are now forward of the background layer.

  4. Choose File > Save and File > Close. Leave the student.site window open for the next part of this lesson.
  • + Share This
  • 🔖 Save To Your Account