DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
View Events Video Library
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Integrating PostgreSQL Databases with ANF: Join this workshop to learn how to create a PostgreSQL server using Instaclustr’s managed service

Mobile Database Essentials: Assess data needs, storage requirements, and more when leveraging databases for cloud and edge applications.

Monitoring and Observability for LLMs: Datadog and Google Cloud discuss how to achieve optimal AI model performance.

Automated Testing: The latest on architecture, TDD, and the benefits of AI and low-code tools.

Related

  • Living in a World Without Neil Peart
  • Robust Exception Handling
  • Reasons to Use Tailwind CSS in React Native Development Projects
  • Build an AI Chatroom With ChatGPT and ZK by Asking It How!

Trending

  • Future Skills in Cybersecurity: Nurturing Talent for the Evolving Threatscape
  • AWS Amplify: A Comprehensive Guide
  • Microservices With Apache Camel and Quarkus
  • What Is a Flaky Test?
  1. DZone
  2. Coding
  3. Frameworks
  4. Adding an Absolutely Positioned Header to Reveal.js

Adding an Absolutely Positioned Header to Reveal.js

Raymond Camden user avatar by
Raymond Camden
·
Apr. 04, 14 · Interview
Like (0)
Save
Tweet
Share
7.03K Views

Join the DZone community and get the full member experience.

Join For Free

I'm a big fan of reveal.js. It is a lightweight HTML-based presentation framework that just works well for me. I switched over to it a while ago and enjoy working with it. Every now and then though I run into an issue that is a bit hard to handle with it. Yesterday I was working on my cfObjective presentation and created the slide you see below.

As you can see, the most important part of the slide is covered by the header. This is unacceptable! Unfortunately, it is difficult to reposition the h1 (or h2) element within a Reveal.js slide. If you set the position to absolute and use 0/0 for top and left, you end up at the top left of the section element, not the top left of the screen. You can use negative values, but that felt wrong to me, and I was worried about what would happen on a smaller screen when I presented.

I raised the issue on Twitter (where all important things should be discussed, am I right?) and Rey Villalobos (@planetoftheweb) came up with a good solution. He was ok with me sharing this on my blog, but note that any mistakes in the description are entirely his my fault.

First, you need to add an element to handle the header, but place it outside the div for your slides.

<!-- In between the <div="reveal"> and the <div class="slides">-->
<header style="position: absolute;top: 50px; left: 100px; z-index:500; font-size:100px;background-color: rgba(0,0,0,0.5)"></header>
<!-- In between the <div="reveal"> and the <div class="slides">-->

(Note - those top and left values are a bit arbitrary. Ditto for the RGBA color.)

Then - for each slide - use CSS to specify the content for the element.

<section data-state="header1">
<style>.header1 header:after { content: "Header 1 Example"; }</style>
<p>header1 example</p>
</section>

Note - when you add a state attribute to a slide in Reveal, the framework automatically applies the state name to the class of the div wrapping all the slides, which means it also impacts that earlier header. As soon as you leave that slide, the class is removed, which means the content dynamically added via CSS (you did know you could do that, right?) is also removed.

Here is the updated slide.

There is one small caveat to this post that I don't have an answer for yet (but check the comments, going to bug Rey until he can figure out a fix) - how to modify the position of the header so it is right aligned. You could probably just use a second DOM element (a div perhaps) but that seems wrong.

Element CSS Framework twitter POST (HTTP) Fault (technology) Attribute (computing) Blog

Published at DZone with permission of Raymond Camden, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Living in a World Without Neil Peart
  • Robust Exception Handling
  • Reasons to Use Tailwind CSS in React Native Development Projects
  • Build an AI Chatroom With ChatGPT and ZK by Asking It How!

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: