CSS margin-left Свойство
Пример
Установите левое поле для элемента <p> на 30 пикселей:
p.ex1 {
margin-left: 30px;
}
Подробнее примеры ниже.
Определение и использование
Свойство margin-left
задает левое поле элемента.
Примечание: Допустимы отрицательные значения.
Значение по умолчанию: | 0 |
---|---|
Inherited: | no |
Animatable: | yes, see individual properties. Читайте о animatable |
Version: | CSS1 |
Синтаксис JavaScript: | object.style.marginLeft="100px" |
Поддержка браузера
Номера в таблице указывают первую версию браузера, которая полностью поддерживает свойство.
Свойство | |||||
---|---|---|---|---|---|
margin-left | 1.0 | 6.0 | 1.0 | 1.0 | 3.5 |
Синтаксис CSS
margin-left: length|auto|initial|inherit;
Значения свойств
Значение | Описание | |
---|---|---|
length | Задает фиксированное левое поле в пикселах, PT, cm и т.д. Значение по умолчанию — 0px. Допустимы отрицательные значения. Читать о единицах длины | |
% | Задает левое поле в процентах от ширины содержащего элемента | |
auto | Обозреватель вычисляет левое поле | |
initial | Присваивает этому свойству значение по умолчанию. (Читайте о initial) | |
inherit | Наследует это свойство из родительского элемента. (Читайте о inherit) |
Другие примеры
Пример
Установите левое поле для элемента <p> до 10% ширины контейнера:
p.ex1 {
margin-left: 10%;
}
Пример
Установите левое поле для элемента <p> на 2 EM:
p.ex1 {
margin-left: 2em;
}
Похожие страницы
CSS Справочник: CSS Margin
HTML DOM Справочник: marginLeft Свойство