Przerwa w CSS przed właściwością
Przykład
Zawsze wstawiaj podział strony przed elementem <h1>:
@media print
{
h1 {
break-before: always;
}
}
Definicja i użycie
Właściwość break-before
określa, czy podział strony, podział kolumny lub podział regionu powinien wystąpić przed określonym elementem.
Właściwość break-before
rozszerza właściwość CSS2 .
page-break-before
Używając break-before
, możesz powiedzieć przeglądarce, aby podzieliła stronę, kolumnę lub region przed elementem, do którego break-before
zostanie zastosowana właściwość, lub uniknąć podziału elementu na dwie strony.
Domyślna wartość: | automatyczny |
---|---|
Dziedziczny: | nie |
Animowalny: | nie. Przeczytaj o animacji |
Wersja: | CSS3 |
Składnia JavaScript: | obiekt .style.breakBefore="zawsze" |
Obsługa przeglądarki
Liczby w tabeli określają pierwszą wersję przeglądarki, która w pełni obsługuje tę właściwość.
Property | |||||
---|---|---|---|---|---|
break-before | 50.0 | 10.0 | 65.0 | 10.0 | 37.0 |
Składnia CSS
break-before: auto|all|always|avoid|avoid-column|avoid-page|avoid-region|column|left|page|recto|region|right|verso|initial|inherit;
Wartości nieruchomości
Value | Description |
---|---|
auto | Default. Automatic page/column/region break before the element |
all | Always insert a page-break right before the principal box |
always | Always insert a page-break before the element |
avoid | Avoid a page/column/region break before the element |
avoid-column | Avoid a column-break before the element |
avoid-page | Avoid a page-break before the element |
avoid-region | Avoid a region-break before the element |
column | Always insert a column-break before the element |
left | Insert one or two page-breaks before the element so that the next page is formatted as a left page |
page | Always insert a page-break before the element |
recto | Insert one or two page-breaks before the principal box so that the next page is formatted as a recto page |
region | Always insert a region-break before the element |
right | Insert one or two page-breaks before the element so that the next page is formatted as a right page |
verso | Insert one or two page-breaks before the principal box so that the next page is formatted as a verso page |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
Więcej przykładów
Przykład
Aby upewnić się, że wszystkie nowe rozdziały po wydrukowaniu powinny zaczynać się na właściwej stronie (jak w książce), możesz użyć break-before: right dla wszystkich elementów <h1>:
@media print
{
h1 {
break-before: right;
}
}
Przykład
Zawsze wstawiaj podział regionu przed <ul> elementami w regionie:
.region ul {
break-before: region;
}
}