【问题标题】:Can I put a caption on the lower right in Reveal.js?我可以在 Reveal.js 的右下角添加标题吗?
【发布时间】:2014-05-08 13:29:10
【问题描述】:

我有一个使用大量背景图片的 Reveal.js 幻灯片:

<section data-background="latimes.png">
    <small class="caption">[Some Text](http://a.link.com/whatever)</small>
    <aside class="notes">some notes</aside>
  </section>

我想在每张幻灯片的左下角为每张图片添加一个标题/链接。

我尝试设置自定义类

.reveal .caption a {
  background: #FFF;
  color: #666;
  padding: 10px; 
  border: 1px dashed #999;
}

.reveal .caption {
  postion: absolute; 
  bottom: 0px;
  left: 50px;
}

但它似乎对布局没有任何影响。元素检查器似乎不能很好地与 Reveal.js 一起工作,这使得这很难排除故障。有没有一种好方法可以在reveal.js中将一块文本强制到屏幕的一角?

【问题讨论】:

  • 我可以在.reveal .caption 上设置边距——margin-top: 700px; margin-right: 1000px; 或多或少在我的屏幕上起作用。但这似乎坏了。

标签: css reveal.js


【解决方案1】:

这可能有点棘手的原因是父节点有一些设置的默认值。

Reveal的初始化中设置宽度和高度为100%:

Reveal.initialize({
    width: "100%",
    height:"100%"
});

确保幻灯片(即section)使用整个空间:

.full {
    height:100%;
    width:100%;  
}

最后设置标题的位置:

.caption {
     bottom:0px;
     right:0px;
     position:absolute;
}

full code

【讨论】:

    【解决方案2】:

    您能否提供一个具有 .reveal 类的 HTML 示例?将position:absolute 添加到您的选择器规则中。如果您希望标题与每张幻灯片的底角齐平,最好将位置设置为bottom:0px 而不是top

    例如:

    <style type="text/css">
    .reveal .reveal_section {
        position: relative;
    }
    .reveal .caption {
        position: absolute; 
        bottom: 0px;
        left: 50px;
    }
    .reveal .caption a {
        background: #FFF;
        color: #666;
        padding: 10px; 
        border: 1px dashed #999;
    }
    </style>
    <div class="reveal">
    <section class="reveal_section" data-background="latimes.png">
        <small class="caption">[Some Text](http://a.link.com/whatever)</small>
        <aside class="notes">some notes</aside>
    </section>
    </div>
    

    【讨论】:

    • 添加了示例 HTML 和更好的 CSS。好像没什么效果。
    • 您需要通过将其样式设置为position: relative来使父容器相对于自身。
    • “父容器”是指...哪个?部分?
    • 是的,section 元素。如果每张幻灯片都有一个section 元素,而section 元素是每张幻灯片的容器。
    • 我已经尝试过这个(以及其他几种位置组合),但未能达到原始问题描述的效果。有没有人能够解决这个问题?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-09-30
    • 2011-01-02
    • 2013-06-15
    • 1970-01-01
    • 2020-08-27
    • 1970-01-01
    • 2019-08-20
    相关资源
    最近更新 更多