Spec-Zone.ru › CSS

shape-margin

Базовая линия Широко доступна

Эта функция хорошо зарекомендовала себя и работает на многих устройствах и версиях браузеров. Она доступна в браузерах с января 2020 года.

  • Подробнее
  • Полная совместимость
  • Отправить отзыв

Свойство shape-margin CSS задаёт отступ для фигуры CSS, созданной с помощью shape-outside.

Попробуйте

Отступ позволяет настроить расстояние между краями фигуры (элемента с float) и окружающим содержимым.

Синтаксис

/* <length> values */
shape-margin: 10px;
shape-margin: 20mm;

/* <percentage> value */
shape-margin: 60%;

/* Global values */
shape-margin: inherit;
shape-margin: initial;
shape-margin: revert;
shape-margin: revert-layer;
shape-margin: unset;

Значения

<length-percentage>

Устанавливает отступ фигуры до значения <length> или до <percentage> ширины содержащего блока элемента.

Формальное определение

Начальное значение 0
Применяется к элементам с float
Наследуется нет
Проценты относятся к ширине содержащего блока
Вычисленное значение как указано, но с относительными длинами, преобразованными в абсолютные
Тип анимации длина, процент или calc();

Формальный синтаксис

shape-margin = 
<length-percentage [0,∞]>

<length-percentage> =
<length> |
<percentage>

Примеры

Добавление отступа к многоугольнику

HTML

<section>
  <div class="shape"></div>
  We are not quite sure of any one thing in biology; our knowledge of geology is
  relatively very slight, and the economic laws of society are uncertain to
  every one except some individual who attempts to set them forth; but before
  the world was fashioned the square on the hypotenuse was equal to the sum of
  the squares on the other two sides of a right triangle, and it will be so
  after this world is dead; and the inhabitant of Mars, if one exists, probably
  knows its truth as we know it.
</section>

CSS

section {
  max-width: 400px;
}

.shape {
  float: left;
  width: 150px;
  height: 150px;
  background-color: maroon;
  clip-path: polygon(0 0, 150px 150px, 0 150px);
  shape-outside: polygon(0 0, 150px 150px, 0 150px);
  shape-margin: 20px;
}

Результат

Спецификации

Спецификация
CSS Shapes Module Level 1
# shape-margin-property

Совместимость с браузерами

Рабочие столы Мобильные устройства
Chrome Edge Firefox Opera Safari Chrome Android Firefox for Android Opera Android Safari на iOS Samsung Internet WebView Android
shape-margin 37 79 62 24 10.110.1 37 62 24 10.3 3.0 37

См. также

  • CSS фигуры
  • Обзор фигур CSS
  • shape-outside
  • shape-image-threshold
  • <basic-shape>

© 2005–2024 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/CSS/shape-margin

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API