Recipe 1.16. Using Relative PositioningProblemYou want to place content based on its position in the document. In other words, the element's position is modified relative to its natural position as rendered by the browser. Solution
Use the position property with the relative value in the style sheet. Also add
top
,
left
or both properties to
Using the following CSS rule on the image, the image was able to move over the paragraph content in Figure 1-39:
.relative {
position: relative;
top: 100px;
left: 20px;
}
Figure 1-39. Relative positioning places an element based on its location within the document's natural flow
Discussion
Unlike absolute positioning, the sample code doesn't start at the top and left edges of the window. Instead, it begins where
p
elements would be if left alone. The code
See AlsoW3C 2.1 specification on relative positioning at http://www.w3.org/TR/CSS21/visuren.html#relative-positioning and W3Schools tutorial on positioning at http://www.w3schools.com/css/css_positioning.asp. |
Recipe 1.17. Using CSS in Adobe DreamweaverProblemYou use Dreamweaver for creating and editing web pages and want to use its CSS features. Solution
Use the CSS Styles Panel to create, edit, delete, and view CSS styles (see Figures 1-40 and 1-41). You have several ways to work with styles sheets. While editing an HTML page, you can attach an external style sheet through the CSS Styles panel or start a new CSS document (click File
Figure 1-40. Start a new CSS file in Dreamweaver
Figure 1-41. Enter and edit styles in Dreamweaver's CSS document
Another option is to use the Code or Split view and enter the CSS directly into the code for inline and internal style sheets.
You can view CSS properties by categories, such as font, background, and border. You can switch to List view, an alphabetical list of properties. Figure 1-42. Use Dreamweaver's CSS Panel to attach an external style sheet
DiscussionIf you add styles to content within an HTML page in Dreamweaver, using Properties, the application automatically adds inline CSS (see Figure 1-43). As you select fonts and color to selected text, Dreamweaver creates an internal style sheet rather than use font element. In older versions of Dreamweaver, the code would look like the following: Figure 1-43. Dreamweaver automatically creates new styles when assigning font and colors to text
<font face="georgia, times new roman, serif" color="#ff0000" size="2">This is text.</font> You can review the style sheet generated by Dreamweaver (see Figure 1-44). Figure 1-44. Review the current document's styles in the CSS panel
See AlsoAdobe's Best Practices of CSS selectors http://www.adobe.com/products/dreamweaver/bestpractices/css/ and Dreamweaver home at http://www.adobe.com/products/dreamweaver/. |