gpt4 book ai didi

javascript - 处理溢出的 Reveal JS 幻灯片的最佳方法

转载 作者:太空狗 更新时间:2023-10-29 14:14:17 26 4
gpt4 key购买 nike

我正在做一个元素,我正在使用 Reveal JS 以幻灯片的形式向用户展示数据。

有时我发现文本溢出视口(viewport)。

因此,如图所示,文本不可见

enter image description here

我试过根据屏幕高度动态减小文本大小,如下所示:

var $present_section = $('section.present');
var section_bottom = $present_section.offset().top + $present_section.height();
var allowed_height = $(document).height() - $present_section.offset().top;

if (section_bottom > allowed_height) {
var cur_font_size = parseInt($present_section.css('font-size'));
$present_section.css('font-size', cur_font_size - 1);
}

在递归循环中运行这段代码会调整 <section>的字体大小以适应文档高度。

有没有更好的方法或插件来处理这个问题而不减少幻灯片中的字符数?

最佳答案

定义CSS类scrollable-slide:

.scrollable-slide {
height: 800px;
overflow-y: auto !important;
}

如果幻灯片太大,则定义将上述 CSS 类添加到幻灯片的监听器。为此,您将需要 jQuery。

function resetSlideScrolling(slide) {
$(slide).removeClass('scrollable-slide');
}

function handleSlideScrolling(slide) {
if ($(slide).height() >= 800) {
$(slide).addClass('scrollable-slide');
}
}

Reveal.addEventListener('ready', function (event) {
handleSlideScrolling(event.currentSlide);
});

Reveal.addEventListener('slidechanged', function (event) {
resetSlideScrolling(event.previousSlide)
handleSlideScrolling(event.currentSlide);
});

如果你想在可滚动时摆脱 box-shadowbackground ,那么添加这些 CSS 样式:

.scrollable-slide::before {
background: none !important;
}

.scrollable-slide::after {
box-shadow: none !important;
}

引用资料:

关于javascript - 处理溢出的 Reveal JS 幻灯片的最佳方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35237862/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com