Help:Wiki University Wikitext--Position - Relative

From FamilySearch Wiki
Jump to navigation Jump to search





Additional Helps

Default positioning[edit | edit source]

We have seen thus far that text, images, etc. position themselves on a page in the order they were loaded. If text was placed first and an image next, the text would be above the image. What if we want to position these items differently than how the browser wants to do it? Here is where position attributes come into play.

Position attribute[edit | edit source]

Position attributes allow you to place objects in precise locations on a page either independent or in relation to whatever else is on the page.

Property values[edit | edit source]

There are six possible property values, but only two really have any use in FamilySearch Wiki:

  • Relative position - places objects in relation to where your browser placed it.
  • Absolute position- places objects in relation to the entire page and it covers up whatever was in that spot whether it be text, images, etc. or another absolutely positioned object.

Relative positioning[edit | edit source]

  • First you need to create a div container with a width and a height in the inline styling: "position:relative".
  • When you place a relative positioned object on a page, whatever follows will move down the page to compensate. If the relative positioned object is 100 pixels high, text, images, etc. will move down the page 100 pixels.
  • The coding for relative positioning is placed in opening div tags:
<div style="position:relative; width:100px; height:100px"></div>

Main use for relative positioning in the wiki[edit | edit source]

  • The main use is to act like a container for absolute positioned objects like text, images, tables, etc.
  • This ability to act as a container makes it possible to position objects absolutely inside a relative positioned object, and if you move the relative positioned object, all the absolute positioned objects inside will move with it and keep their positions.
  • This is similar to the way cells inside tables behave.

Try these out[edit | edit source]

  • Place a "relative" positioned object that is 300 pixels wide and 100 pixels high between the third and fourth sentence of our Lorem ipsum paragraph.
  • Place a "relative" positioned object after the last sentence that has the following attributes:
    • width is 100%.
    • background-color:blue.
    • border 5 pixels thick and red in color.
    • that is 200 pixels high.

Quick Quiz
  • Relative positioning places objects in relation to the edge and top of the page.
A. True
B. False
  • Relative positioning does not cover objects placed before it was.
A. True
B. False
  • Relative positioning covers up all objects placed after it was.
A. True
B. False