jan*_*ans 48 css markdown reveal.js
我使用reveal.js并在Markdown代码中编写我的幻灯片.现在我想在经典的两列文本布局中显示我的内容(文本,无序的项目符号列表甚至图像).我更喜欢在初始配置中可能更复杂的解决方案,只要在Markdown中实际写入内容仍然很容易.
由于我不想运行本地服务器,因此我在主HTML文件中写下了markdown.
更新:第一个答案表明这应该通过CSS实现.(我相应地更新了我的问题.)但是,我找不到任何描述如何使用CSS.
The*_*aya 34
我正在使用CSS flex,它运行正常.
<style>
.container{
display: flex;
}
.col{
flex: 1;
}
</style>
<div class="container">
<div class="col">
Column 1 Content
</div>
<div class="col">
Column 2 Content
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
J. *_*rew 19
我在外部css文件custom.css中创建了两个ID,我将其附加到我的reveal.js文件中,并在YAML标头中使用字段css:custom.css.
#left {
left:-8.33%;
text-align: left;
float: left;
width:50%;
z-index:-10;
}
#right {
left:31.25%;
top: 75px;
float: right;
text-align: right;
z-index:-10;
width:50%;
}
Run Code Online (Sandbox Code Playgroud)
我在我的降价文档中放置了具有右和左ID的div元素,以产生两列布局.
<div id="right">
- You can place two graphs on a slide
- Or two columns of text
- These are all created with div elements
</div>
Run Code Online (Sandbox Code Playgroud)
该CSS网格布局允许非常灵活的布局,两列格式和更复杂的布局。
对于两列,可以使用以下 CSS 片段。它定义了两个大小相等的列模板,每列模板都是1fr可用宽度的1 个分数 ( ),列之间有 10px 的装订线空间。
.twocolumn {
display: grid;
grid-template-columns: 1fr 1fr;
grid-gap: 10px;
text-align: left;
}
Run Code Online (Sandbox Code Playgroud)
它可以如下使用
<section>
<h2>Slide Title</h2>
<div class="twocolumn">
<div>
Column One
</div>
<div>
Column Two
</div>
</div>
</section>
Run Code Online (Sandbox Code Playgroud)
小智 7
我用两个浮动<div>元素解决了这个问题:
<section>
<div style="text-align: left; float: left;">
<p data-markdown>- This is my first left element</p>
<p data-markdown>- This is my second left element</p>
<!-- more Elements -->
</div>
<div style="text-align: right; float: right;">
<p data-markdown>- This is my first right element</p>
<p data-markdown>- This is my second rightelement</p>
<!-- more Elements -->
</div>
</section>
Run Code Online (Sandbox Code Playgroud)
我发现,如果你想div在p-container中使用降价,你必须将元素包装在-tags中.如果你写入data-markdown父section-Tag,它将被忽略div
我希望我能帮忙!
.multiCol {
display: table;
table-layout: fixed; // don't fudge depending on content
width: 100%;
text-align: left; // matter of taste, makes imho sense
.col {
display: table-cell;
vertical-align: top;
width: 50%;
padding: 2% 0 2% 3%; // some vertical, and between columns
&:first-of-type { padding-left: 0; } // there's nothing before col1
}
}
Run Code Online (Sandbox Code Playgroud)
将其放入您的自定义主题,即在之前
// Theme template ------------------------------
@import "../template/theme";
// ---------------------------------------------
Run Code Online (Sandbox Code Playgroud)
如何使用?- 简单!并且不限于2列:
<section>
<h3>Doing two-column (this headline still full-width)</h3>
<div class='multiCol'>
<div class='col'>
Gallia est omnis divisa in partes tres, quarum unam incolunt Belgae, aliam Aquitani, tertiam qui ipsorum lingua Celtae, nostra Galli appellantur.
</div>
<div class='col'>
Qua de causa Helvetii quoque reliquos Gallos virtute praecedunt, quod fere cotidianis proeliis cum Germanis contendunt, cum aut suis finibus eos prohibent aut ipsi in eorum finibus bellum gerunt.
</div>
</div>
And simply more regular full-width text in the following. But hey, there is also:
<div class='multiCol'>
<div class='col'>Also works for 3 columns...</div>
<div class='col'>...as we can show in...</div>
<div class='col'>...this example here.</div>
</div>
</section>
Run Code Online (Sandbox Code Playgroud)
<table>ist通常被认为是“过时的”(因为它在html早期就被严重滥用于布局目的,而今天在电子邮件中仍然是html ...)但是相反,至少作为layout:table具有许多合法用途的属性,通常是最简单的解决方案,广泛兼容。
小智 5
我找到了以下方法来显示一个元素,它似乎在列布局中
Text going to the right <!-- .element: style="float: right; width: 40%" -->
Text going on the left column <!-- .element: style="width: 40%" -->
Run Code Online (Sandbox Code Playgroud)
但实际上它不适用于右侧的多个元素
我无法完全理解你的意思,但我想你可能会在 ramnathv帖子中找到答案。
---
layout: slide
---
{{{ content }}}
<div class='left' style='float:left;width:{{left.width}}'>
{{{ left.html }}}
</div>
<div class='right' style='float:right;width:{{right.width}}'>
{{{ right.html }}}
</div>
Run Code Online (Sandbox Code Playgroud)
这对我有用