Propriedade de órfãos de estilo
Exemplo
Altere os órfãos e verifique a impressão ou a visualização de impressão:
<html>
<head>
<script>
function ChangeOrphans()
{
document.getElementById("p1").style.orphans = document.getElementById("orphans").value;
}
</script>
<style>
.othercontent
{
width: 400px;
border-top: 19cm solid #c3c3c3;
}
@page
{
/* set size of printed page */
size:21cm 27cm;
margin-top:2cm;
}
@media print
{
.orphans
{
orphans:2;
}
}
</style>
</head>
<body>
<div class="othercontent">
<input id="orphans" value="2">
<button onclick="ChangeOrphans();">Change orphans</button>
<p style="font-size:120%" id="p1">
Change orphans and see the print preview.<br>
Line 2<br>
Line 3<br>
Line 4<br>
Line 5<br>
Line 6<br>
Line 7<br>
Line 8<br>
</p>
</body>
</html>
Tente você mesmo "
Definição e uso
A propriedade órfãos define ou retorna o número mínimo de linhas para um elemento que deve estar visível na parte inferior de uma página (para impressão ou visualização de impressão).
A propriedade órfãos afeta apenas elementos em nível de bloco.
Dica: orphans:5 significa que pelo menos 5 linhas devem estar visíveis acima da quebra de página.
Dica: Consulte a propriedade de viúvas para definir ou retornar o número mínimo de linhas para um elemento que deve estar visível na parte superior de uma página.
Suporte ao navegador
Property | |||||
---|---|---|---|---|---|
orphans | Yes | Not supported | Not supported | Not supported | Yes |
Sintaxe
Retorne a propriedade órfãos:
object.style.orphans
Defina a propriedade órfãos:
object.style.orphans = "number|initial|inherit"
Valores de propriedade
Value | Description |
---|---|
number | An integer that specifies the minimum number of visible lines. Negative values are not allowed. The default value is 2 |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
Detalhes técnicos
Valor padrão: | 2 |
---|---|
Valor de retorno: | Uma String, representando o número mínimo de linhas a serem impressas na parte inferior da página |
Versão CSS | CSS2 |
❮ Objeto de estilo