【问题标题】:Why is this background not being tiled correctly?为什么这个背景没有正确平铺?
【发布时间】:2016-06-02 07:08:05
【问题描述】:

我修改了reveal.js 视差背景,使其大小调整为每个PDF 导出页面平铺一次。但是,根据reveal.js presentation size,平铺会变得混乱。有时瓦片高度稍大,这个误差会不断累积。

问题:

  • 是什么导致平铺弄乱了?
  • 哪些演示文稿尺寸不会弄乱? (960x678 有效,但 960x700 无效)
  • 如何修改reveal.js,以便正确平铺所有演示文稿尺寸?

您可以在这里试用:

这是乱七八糟的平铺屏幕截图:


最后,这是我修改reveal.js的方式:

我改变了这一行:

dom.background.style.backgroundSize = config.parallaxBackgroundSize;

到这里:

if ( isPrintingPDF() ) {
    var slideSize = getComputedSlideSize( window.innerWidth, window.innerHeight );

    // Dimensions of the PDF pages; copied from another part of reveal.js
    var pageWidth = Math.floor( slideSize.width * ( 1 + config.margin ) ),
        pageHeight = Math.floor( slideSize.height * ( 1 + config.margin  ) );

    dom.background.style.backgroundSize = pageWidth + 'px ' + pageHeight + 'px';
} else {
    dom.background.style.backgroundSize = config.parallaxBackgroundSize;
}

【问题讨论】:

    标签: javascript css reveal.js


    【解决方案1】:

    在reveal.js中这改变了页面的大小:

            // Let the browser know what page size we want to print
            injectStyleSheet( '@page{size:'+ pageWidth +'px '+ pageHeight +'px; margin: 0;}' );
    
            // Limit the size of certain elements to the dimensions of the slide
            injectStyleSheet( '.reveal section>img, .reveal section>video, .reveal section>iframe{max-width: '+ slideWidth +'px; max-height:'+ slideHeight +'px}' );
    

    【讨论】:

    • 我从reveal.js的那部分复制了pageWidthpageHeight的计算。所以背景图块大小和页面大小应该匹配。 (根据通过浏览器调试工具进行的检查,它们确实匹配 AFAIK...)
    • 检查绝对位置和相对位置,这可能会破坏您的设计
    猜你喜欢
    • 1970-01-01
    • 2014-01-08
    • 1970-01-01
    • 2011-01-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多