Reveal.js: Reducing size of `pre` block around `code` block

Created on 22 Apr 2017  路  3Comments  路  Source: hakimel/reveal.js

Currently the drop-shadow border around pre blocks takes up unneeded vertical space around nested code blocks. Is this the intended behaviour?
Here is an example:

<section>
    <pre>
        <code data-noescape data-trim class="lang-csharp hljs">
            public interface IFoo
            {
                void DoMagic(string s);
            }
        </code>
    </pre>
</section>

screenshot from 2017-04-22 15-35-57
(Notice the space above and below the code block and the border)

Am I doing something wrong here?

Replacing

reveal pre {
  display: block;

with

reveal pre {
  display: inline-grid;

in css/theme/template/theme.scss (and running grunt css-themes) seems to fix the issue for me:
screenshot from 2017-04-22 15-36-54

question

Most helpful comment

Is there a fix to do this without removing the line break between pre and code tags?

All 3 comments

You're leaving a line of whitespace between the <pre> and <code> tags. The default Reveal styles only the code tag, hence there appears to be this issue for you. While I'm not too sure what the solution should be, I don't believe modifying the display is the right way to go as it can lead to unexpected behaviour. For now, a quick fix for you is to adjust the whitespace between pre and code.

So removing the linebreak and writing

<pre><code>
...
</code></pre>

instead of

<pre>
  <code>
  ...
  </code>
<pre>

fixes the problem.

@demoneaux Thanks!

Is there a fix to do this without removing the line break between pre and code tags?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MurhafSousli picture MurhafSousli  路  5Comments

gre picture gre  路  5Comments

AnnotatedJS picture AnnotatedJS  路  5Comments

sundorf picture sundorf  路  5Comments

OscarDeDios picture OscarDeDios  路  3Comments