Lesson Practice 7-1:
Using Layout
& Positioning Properties
Practice 7 - Using Layout Properties
Task 1 - Using the Display Property
- Open the nocss.htm file in Notepad++. Immediately
Save the file in your CSS folder as layout1.htm (from
your text folder)
- Open your ulist.htm file and copy the entire unordered list. Paste
before the first h3 element in layout1.
- In the title element, add the title: Using The
Display Property.
- Add an h2 header to the top of the page with the same text as in
the title.
- Add an internal style sheet.
- Create and apply a class to center the h2 element.
- Create a class named .inline, setting the
display property to inline.
- Apply the class to each list item.
- Move the enitre first h3 element to the beginning of the first paragraph,
just inside the opening tag.
- Apply the inline class to the moved h3 element.
- Preview the file to see the effects. Trouble-shoot as needed.
- Save the file again.
Task 2 - Using Absolute Positioning
- Open a classes2.htm in Notepad++. Immediately Save the file
in your CSS folder as layout2.htm.
- In the title element, add the title: Using Absolute
Positioning
- Add an h2 header to the top of the page with the same text as in
the title.
- Create and apply a class to center the h2 element.
- To the red class, add declarations to make the position absolute,
the top set at 50 pixels, and the width 250 pixels.
- To the white class, add declarations to make the position absolute,
the top set at 50 pixels, the left set at 300 pixels and the width 250
pixels.
- To the blue class, add declarations to make the position absolute,
the top set at 50 pixels, the left set at 600 pixels and the width 250
pixels.
- Preview the file to see the effects. You should see the three color
block set in 'columns' on the page. Trouble-shoot as needed.
- Change the width of your preview window to see that the blocks do
not change as the available page width changes. (The centered h2 element
changes.)
- Note also that the lengths of the three blocks are different, because
of the different amounts of content text.
- To each of the color classes, add a declaration to make the height
460 pixels.
- Preview again to see that the blocks are now the same height.
- Save the file again.
Task 3 - Using Percentage Block Positioning Within
Absolute
- Reopen layout2.htm if needed in Notepad++. Immediately Save
the file in your CSS folder as layout3.htm.
- In the title element, add the title: Using Percentage
Block
Positioning Within Absolute
- Change the title heading to match the title element.
- Change each color class, change the top property value to 10% and
the width property to 28%.
- In the red class, add set the left edge to be at 2%.
- In the white class, change the left edge to be 34%.
- In the blue class, change the left edge to be 66%.
- Preview the file to see the effects. Change the width of your preview
window to see that the blocks now change as the available page width
changes. if the window gets very narrow, the column lengths may not
stay even as a block needs more room for its content. If any property
does not work, trouble-shoot to fix it.
- Save the file again.
Task 4 - Using Relative Positioning of a Block Within
a Block
- Reopen layout3.htm if needed in Notepad++. Immediately Save
the file in your CSS folder as layout4.htm.
- In the title element, add the title: Using Relative
Positioning of a Block Within a Block
- Change the title heading to match the title element.
- Add a .redh3 class with declarations to
set relative positioning, top and left side postitions at 10 pixels
each.
- Apply the redh3 class to the h3 element within the red div.
- Preview the file to see the effects. Notice that the h3 element has
been repositioned with 10 pixels of space above it and to its left,
relative to where it was before within the division.
- Add a .whiteh3 class with declarations
to set relative positioning, top and right side positions at 10 pixels
each.
- Apply the whiteh3 class to the h3 element within the white div.
- Preview the file to see the effects. Notice that the h3 element has
been repositioned with 10 pixels of space above it and to its right,
relative to where it was before within the division.
- This position does not look good, so chnge the right
positioning, to left position at 40 pixels.
- Preview to see the effect.
- Add a .blueh3 class with declarations to
set relative positioning, top position at 10 pixels
and left position at 80 pixels
each.
- Apply the blueh3 class to the h3 element within the blue div.
- Preview, changing the width of your preview
window to see how the heading blocks behave inside their div blocks.
You will notice that the headings do not wrap nicely.
- Add a width declaration to each colorh3 class, setting the red width
to 85%, the white width to 75% and the blue width to 65%.
- Preview to see the behavior now. If any property
does not work, trouble-shoot to fix it.
- Save the file again.
Task 5 - Adding Layout Links to Your HTML Index
Page
- Open your style sheet. Change the font size of the dt rule
to 14pt, the font size of the regular and visited link rule to 9pt,
and the font size of the link hover rule to 11pt. Save and close the
style sheet.
- Open the index.htm file from your HTML Practice Site.
- Add CSS Layout as a new term in the list.
- Add the titles of the five Layout files as definitions.
- Link the titles to their appropriate files.
- Add an embedded style sheet.
- Create a rule for the dd class with a declaration to make them display
inline.
- Add line breaks, only as needed, to control the flow of each section
of links
- Preview to see the result; troubleshoot as needed.
- Test your links, save the file and publish the new files.
|