Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

markdown - Shrink font size and right-align fonts for reveal.js presentations

HI there: I am writing some lectures in markdown and converting them to reveal.js slides. Honestly, it's working great, except there are some basic features I'd like to modify but I just don't know my way around CSS.

How can I:

  1. left-align most of the text on the slides.
  2. shrink the font size of the body text on most of the slides. I'd like to do this in general, but I specifically have to do this for the page of references.

Thank you!!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The first step would be to go to the <head></head> section. At the bottom make a new <style></style> tag for your custom CSS styling.

To align a piece of text on a slide in reveal.js

Create a new class called left. .left { } Inside your class, put text-align: left;. Your code should look like this:

<style>
  .left {
    text-align: left;
  }
</style>

In your HTML, add the left class to any of your elements. Eg.

<section class="left">Slide 1</section>

Or:

<section>
  I'm just normal text.
  <p class="left">But I'm not!</p>
</section>

Change the font size of an element in reveal.js

The first thing to do is create a new class as we did for aligning text.

<head>
  <!-- Custom Styles For Our Presentation -->
  <style>
    .left {
      text-align: left;
    }
    
    .size {
      
    }
  </style>
</head>

Then add the following: font-size: /*custom font size*/; You can change the size there. CSS also has some built-in styles for this such as large, medium and small. After that, just add the class to your chosen elements. You can also add to classes to one element like this: <section class="left size">Slide 1</section>. Your finishing code could be something like this:

<head>
  <!-- Custom Styles For Our Presentation -->
  <style>
    .left {
      text-align: left;
    }
    
    .size {
      font-size: 80px;
    }
  </style>
</head>
<body>
  <div class="reveal">
    <div class="slides">
      <section class="left size">Slide 1</section>
      <section>Slide 2 <p class="left">Text aligned left</p></section>
    </div>
  </div>
</body>

(:


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...