CSS中page-break-after属性

在CSS中,page-break-after是一个属性,它控制了元素后的分页行为。

当你打印一个网页的时候,page-break-after属性可以设置在元素后插入一个分页符,将内容分割到新的一页上。它的值可以是以下之一:

  • auto: 默认值。自动分页。
  • always: 在元素后总是插入分页符。
  • avoid: 避免在元素后插入分页符。
  • left: 插入分页符,使得下一页在左侧(仅用于双面打印)。
  • right: 插入分页符,使得下一页在右侧(仅用于双面打印)。

例如:

<div style="page-break-after: always">This content is on page 1.</div>
<div>This content is on page 2.</div>

使用JavaScript,你也可以动态地改变一个元素的page-break-after属性:

var div = document.getElementById("myDiv");
div.style.pageBreakAfter = "always";

但是请注意,page-break-after属性只在打印预览或实际打印时才有效。在常规浏览模式下,你无法看到分页效果。

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
CSS文速查手册 CSS Properties Reference 样式表属性   字体 Font fontcolorfont-familyfont-sizefont-size-adjustfont-stretchfont-stylefont-weighttext-decorationtext-underline-positiontext-shadowfont-varianttext-transformline-heightletter-spacingword-spacing  文本 Text text-indenttext-overflowvertical-aligntext-alignlayout-flowwriting-modedirectionunicode-bidiword-breakline-breakwhite-spaceword-wraptext-autospacetext-kashida-spacetext-justifyruby-alignruby-positionruby-overhangime-modelayout-gridlayout-grid-charlayout-grid-char-spacinglayout-grid-linelayout-grid-modelayout-grid-type  背景 Background backgroundbackground-attachmentbackground-colorbackground-imagebackground-positionbackground-positionXbackground-positionYbackground-repeatlayer-background-colorlayer-background-image  定位 Positioning positionz-indextoprightbottomleft  尺寸 Dimensions heightmax-heightmin-heightwidthmax-widthmin-width  布局 Layout clearfloatclipoverflowoverflow-xoverflow-ydisplayvisibility  外补丁 Margins marginmargin-topmargin-rightmargin-bottommargin-left  轮廓 Outlines outlineoutline-coloroutline-styleoutline-width  边框 Borders borderborder-colorborder-styleborder-widthborder-topborder-top-colorborder-top-styleborder-top-widthborder-rightborder-right-colorborder-right-styleborder-right-widthborder-bottomborder-bottom-colorborder-bottom-styleborder-bottom-widthborder-leftborder-left-colorborder-left-styleborder-left-width  内容 Generated Content include-sourcequotescontentcounter-incrementcounter-reset  内补丁 Paddings paddingpadding-toppadding-rightpadding-bottompadding-left  列表项目 Lists list-stylelist-style-imagelist-style-positionlist-style-typemarker-offset  表格 Table border-collapseborder-spacingcaption-sideempty-cellstable-layoutspeak-header  滚动条 Scrollbars scrollbar-3d-light-colorscrollbar-highlight-colorscrollbar-face-colorscrollbar-arrow-colorscrollbar-shadow-colorscrollbar-dark-shadow-colorscrollbar-base-color  打印 Printing pagepage-break-afterpage-break-beforepage-break-insidemarksorphanssizewidows  声音 Aural voice-familyvolumeelevationazimuthstressrichnessspeech-ratecuecue-aftercue-beforepausepause-afterpause-beforepitchpitch-rangeplay-duringspeakspeak-numeralspeak-punctuation  其它属性 Classification behaviorzoomcursorfilter

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

不会理财的程序员不是好摄影师

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值