Custom CSS recipes for PDF templates

PDF Templates in ScreenSteps are created with HTML, CSS, and Javascript. This means you can customize how things look by adding your own CSS. This article contains CSS examples that you can use in the Custom CSS tab of the PDF Template editor in the ScreenSteps admin area to change the appearance of your PDF output.

Set the maximum height for images

By default images in a PDF document can be up to 4 inches tall. This CSS will change the max-height for the image to 3 inches.

#content .image img {
  max-height: 3in;
}

By default the title page logo has a top margin of 80pt and a maximum height of 100px. Here is an example that changes the top margin to 0pt and 400 pixels.

#title-page-logo-image {
  margin-top: 0pt;
  max-height: 400px;
}

Target the title page

@page title-page {
  margins: 75pt 30pt 50pt 30pt;
  background-color: red;
}

Resize text in styled text blocks

A text block in ScreenSteps can have a style applied to it. Currently you can assign a style of introduction, alert, tip, info, or warning. Use the following CSS to target text assigned one of these styles.

This example will change the font size for a text block that has the alert style assigned to it. Just change the word alert with introduction, tip, info, or warning for other styles.

.screensteps-textblock.screensteps-wrapper--alert {
  font-size: 10pt;
}

Use a single image for the title page

  1. On the Title Page tab, use the Logo button to select the image.
  2. Add the following to the Custom CSS tab.
@page title-page {
  margin: 0pt;
  @bottom {
    content: none;
  }
}

#title-page-logo-image {
  margin: 0pt;
  max-height: 11in;
}

Customize the "Table of Contents" text

.table-of-contents-title {
  content: 'Customized Table of Contents';
}

Try to keep chapter articles on same page as chapter in table of contents

.chapter-tofc {
  page-break-after: avoid;
}

.article-tofc + .article-tofc {
  page-break-before: avoid;
}

Add content after the title page title

The '\A' will add a newline after the existing title. 'white-space: pre' will cause the newline to be displayed. What you end up with is text on a new line after the title page title.

#title-page-title-text::after {
  content: '\AThis comes after the title';
  white-space: pre;
}

Keep chapter title on same page as article title

#content .chapter {
  page-break-after: avoid;
  display: block;
  height: auto;
}

#content .chapter-title {
  position: relative;
  transform: none;
  top: inherit;
  left: inherit;
}

#content .chapter + .article {
  page-break-before: avoid;
}

Hide chapter title pages

#content .chapter {
  display: none;
}

/* Since chapters no longer have pages don't add page numbers to chapter entries in the T of C. */
#table-of-contents a::after {
  content: '';
}

#table-of-contents .article-tofc a::after {
  content: leader(".") target-counter(attr(href), page);
}

Adjust positioning of chapter title on page

#content .chapter-title {
  vertical-align: top;
  padding-top: 75mm;
}

Adjust positioning of article title

#content .article-title {
  text-align: center;
}

Right-justify the header text

First set the Align Logo setting to Left.

.header-text {
  text-align: right;
}

Set the maximum height for the logo in the header

#header .logo {
  max-height: 25pt;
}

Always add a page break before a level 1 heading

h2.screensteps-heading {
  page-break-before: always;
}

Justify text

.screensteps-textblock {
  text-align:justify;
}

Change spacing between list items

This CSS will change the spacing between all list items. It will not affect the spacing between the first list item and the preceding paragraph.

li:nth-child(n+2) {
  margin-top: 2em;
}

Turn off small caps on the title page

#title-page-title-text {
  font-variant: normal;
}

Fit as many articles on a page as possible

.article {
  page-break-after: auto;
}

#content .chapter {
  page-break-before: always;
}

Insert the title of the current chapter into the header

.chapter-title {
  string-set: chapter-title content()
}

.header-text {
  content: string(chapter-title)
}

Remove spacing between paragraphs

div > p:not(:last-child){
  margin-bottom: 0px;
  margin-top: 0px;
}

div > p:last-child {
  margin-top: 0px;
}

Float images to the right of text

This CSS assumes the following:

  • A heading with an image and text content block underneath it.
  • A Letter page size with Landscape orientation.

You would just need to adjust the max-width properties for other pages sizes/orientations.

.screensteps-textblock {
  float: left;
  max-width: 473pt;
}

.screensteps-image {
  max-width: 250pt;
  float: right;
}

.screensteps-section {
  clear: both;
}

The footer has a footer class applied to it.

.footer {
  ...
}

You can target the footer text as well as the footer page number as well.

.footer .page-number {
  ...
}
.footer-text { 
  ...
}