我正在开发一个项目,我正在使用Reveal JS以幻灯片的形式向用户呈现数据.
有时我发现文本溢出视口之外.
由于该文本不可见,如此图所示
我已经尝试根据屏幕高度动态缩小文本大小,如下所示:
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);
}
Run Code Online (Sandbox Code Playgroud)
在递归循环中运行此代码将调整<section>字体大小以调整文档高度.
有没有更好的方法或插件来处理这个问题而不减少幻灯片中的字符数?