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.
- 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.
- Choose to leave this file open as a reference, or choose File > Close.
- Choose File > Open and browse to locate the file named layout_start.html in the Lesson03 folder. The start page appears.
- Choose File > Save As. Keep the name the same and click on the Site Folder () and select Root (Windows) or Root folder (Mac Os). Click Save.
- Begin this page by selecting the Layer object () from the Basic section of the Objects palette.
- Click and drag the Layer object to the layer_start.html page.
A layer appears in the upper left of the page.
- If the Inspector is not visible, choose Window > Inspector. While the layer is selected, the Inspector is a Layer Inspector.
- Change the name from layer1 to logo in the Name text field; press Return. This will help you identify the layer later.
- 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.
- Using the Standard Editing tool (), click to insert the blinking cursor inside the layer.
- Double-click on the Image Object in the Basic section of the Objects palette. The image Object appears in the layer.
- Using the Image inspector, click on the Browse button () 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.
- 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.
- Click to the right of the logo; a large blinking cursor appears. Press the spacebar once and type The place to learn technical skills.
- Position the cursor over the edge of the layer. When the hand icon () appears, click to select the layer.
Just as with table cells, you can apply a class style to the contents of a layer.
- 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.
- 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.
- Reposition the new layer by positioning the cursor over the edge of the layer. When a hand icon () 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.
- Select Edit > Duplicate to duplicate this layer and put a copy directly on top of the existing layer.
- Choose Edit > Duplicate again. This will provide you with three layers, all positioned on top of one another.
- Using the Object Selection tool (), 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.
- Using the Object Selection tool, select the left layer and type laptop in the Name text field of the Layer Inspector.
- Select the center layer. Type female into the Name text field in the Layer inspector.
- Select the right layer. Type group into the Name text field.
- 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.
- 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.
- Choose File > Save. Leave the file open for the next part of this lesson.
Adding imagery and text
- Position the student.site window so that you can see it at the same time as the layout_start.html file.
- Click on image_1.jpg and drag it into the leftmost layer.
- Drag image_2 into the middle layer.
- Drag image_3 into the rightmost layer.
You will now add another layer that will be used for text.
- Make sure that the Basic section of the Objects palette is visible. Select the Layer object () 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.
- After placing the Layer object, cross your cursor over the side and click when you see the hand icon (). 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.
- With the layer still active, type text into the Name text field in the Layer tab of the Layer Inspector. Press Enter.
- Choose File > Open. When the Open dialog window appears, browse to locate the file named student.txt in the Lesson03 folder, and choose Open.
- Select the paragraph text located under the dashed line and choose Edit > Copy. Then choose File > Close.
- Return to the layer_start.html file, and using the Standard Editing tool (), click inside the new text layer you created. Then choose Edit > Paste.
- Choose Type > CSS DIV select gray_text. The text is changed to gray.
- 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.
- Select the Layer object () 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.
- 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.
- With the layer still active, type background into the Name text field in the Layer tab of the Layer Inspector. Press Enter.
- 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
- Choose Window > Layers to make the Layers palette visible.
- In the Layers palette, select the background layer.
- 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.)
- 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.
- Select the layer named laptop and type 5 into the Z-index text field.
- 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.
- Choose File > Save and File > Close. Leave the student.site window open for the next part of this lesson.