Cascading Style Sheets: Designing for the Web (3rd Edition)

Case 1: No Value is "Auto"

When none of width, margin-left, or margin-right is set to auto, the right margin is ignored and treated as if it had been set to auto; that is, it is the value calculated automatically using the formula shown in Figure 8.17.

For example, if there is a P inside a BODY, and the style sheet reads

BODY { width: 30em } P { width: 25em; margin-left: 3em; margin-right: 3em }

the P will be 25em wide and have a 3em margin on the left, but the right margin will be ignored and will be calculated as 30 25 3 = 2em (assuming no paddings and borders are set elsewhere).

Категории