7.5.1. Percentage Values and Padding

As stated earlier, it's possible toset percentage values for the padding of an element. Percentages arecomputed in relation to the width of the parent element, so they canchange if the parent element's width changes in some way. Forexample, assume the following, which is illustrated in Figure 7-59:

P {padding: 10%; background-color: silver;}


ringtone ringing games tone download mp3







Thursday 30th of October 2014 05:35:26 PM

Nice and Free CSS Templates

This site contains free css templates for your website - Just copy and paste and there you have a stunning website !

Menu und content
dynamic

Menu fixed, content
dynamic

Menu und content
dynamic

3 columns all
dynamic

4 columns all
dynamic

Menu floating

Menu fix, Inhalt u.
Head dynamic

3 columns fix
centered

dynamic mit
Head und Footer

fixed BOX centered

dynamic BOX
centered

fixed Box total
centered
exactly as you specified. Basically, there isn't an easy way tocircumvent this problem, although two possible approaches aredetailed in Chapter 11, "CSS in Action".

Figure 7-27

Figure 7-27. Overlapping text in Explorer

It gets worse, unfortunately. If you apply margins to inlineelements, as was discussed previously, you'll get results fromNavigator 4.x like those shown in Figure 7-28.

Figure 7-28

Figure 7-28. Margins, inline elements, and Navigator 4.x

Let's say you want the line-height of allelements in a document to be one-and-one-half times theirfont-size. You would declare:

BODY {line-height: 1.5;}

This scaling factor of 1.5 is passed down fromelement to element, and at each level the factor is used as amultiplier of the font-size of each element.Therefore, the following markup would be displayed as shown in Figure 8-64 (backgrounds added for illustrative purposes):

Figure 8-48

Figure 8-48. Line-box layout with right justification

Again, all we have here are the pieces of a single line of text which have been stacked on top of one another with their right sides lined up with each other. If we had set the paragraph to have a text-align of center, then the centers of the line boxes would have lined up, and if it were set to justify, then each line box would be forced to be as wide as the paragraph's content area. The difference is made up in letter- and word-spacing, as we see in Figure 8-49.

situation becomes.

Figure 7-20

Figure 7-20. The dangers of document-wide negative-margin rules

Using negative margins with block-level elements such as these can quite obviously be dangerous and is rarely worth the trouble -- but it can also be rewarding. It takes a good deal of practice, and many mistakes, to learn to tell the difference between the two.

computer. So, once you've finished this chapter, you will have a grasp not only of how CSS units work, but perhaps also of a few basic issues that you previously were unaware of.

Above all, though, regardless of how bleak things may seem, keep going! Your perseverance will be rewarded.