HTML and CSS [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

HTML and CSS [Electronic resources] - نسخه متنی

Molly E. Holzschlag

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید






Using Negative Margins


You can also use negative values with margins. This practice is helpful to achieve certain design needs, but it should be used with relative caution because browsers handle negative margins inconsistently.

Typically, negative margins are used to make visual adjustments, to manage workarounds for centering liquid designs in layout, or to offset specific elements outside the box in which they are contained (see Example 11-3).

Example 11-3. Using negative margins to override a containing element

[View full width]


body {font: 14px Verdana, Arial, Helvetica, sans-serif; color: white; background-color:
black;

margin-top: 30px; margin-right: 30px; margin-bottom: 30px; margin-left: 130px;
border: 2px solid white;}
p {

margin-left: -65px; margin-top: 5px; margin-bottom: 0; }

Now the paragraph margins are offset to the body's left margin (see Figure 11-5).

Figure 11-5. Using negative margins to override a containing blockin this case, the body element.

. As with so many issues in CSS, the way browsers implement a property differs. Negative margins fall into this category because they are interpreted differently by different browsers. So use with careand, as a good rule of thumb, if there's an easier way to accomplish the end result, use it.

/ 198