Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gradient background #2510

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,16 @@ All CSS color formats are supported, including hex values, keywords, `rgba()` or
</section>
```

#### Gradient Backgrounds

All CSS gradient formats are supported.

```html
<section data-background-gradient="linear-gradient(to bottom, #ddd, #191919)">
<h2>Gradient</h2>
</section>
```

#### Image Backgrounds

By default, background images are resized to cover the full page. Available options:
Expand Down
4 changes: 4 additions & 0 deletions demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ <h2>Slide Backgrounds</h2>
<img width="178" height="238" data-src="https://s3.amazonaws.com/hakim-static/reveal-js/arrow.png" alt="Down arrow">
</a>
</section>
<section data-background-gradient="linear-gradient(to bottom, #ddd, #191919)">
<h2>Gradient Backgrounds</h2>
<pre><code class="hljs html">&lt;section data-background-gradient="linear-gradient(to bottom, #ddd, #191919)"&gt;</code></pre>
</section>
<section data-background="https://s3.amazonaws.com/hakim-static/reveal-js/image-placeholder.png">
<h2>Image Backgrounds</h2>
<pre><code class="hljs html">&lt;section data-background="image.png"&gt;</code></pre>
Expand Down
5 changes: 4 additions & 1 deletion js/reveal.js
Original file line number Diff line number Diff line change
Expand Up @@ -1180,6 +1180,7 @@
backgroundVideo: slide.getAttribute( 'data-background-video' ),
backgroundIframe: slide.getAttribute( 'data-background-iframe' ),
backgroundColor: slide.getAttribute( 'data-background-color' ),
backgroundGradient: slide.getAttribute( 'data-background-gradient' ),
backgroundRepeat: slide.getAttribute( 'data-background-repeat' ),
backgroundPosition: slide.getAttribute( 'data-background-position' ),
backgroundTransition: slide.getAttribute( 'data-background-transition' ),
Expand All @@ -1199,9 +1200,10 @@
// Create a hash for this combination of background settings.
// This is used to determine when two slide backgrounds are
// the same.
if( data.background || data.backgroundColor || data.backgroundImage || data.backgroundVideo || data.backgroundIframe ) {
if( data.background || data.backgroundGradient || data.backgroundColor || data.backgroundGradient || data.backgroundImage || data.backgroundVideo || data.backgroundIframe ) {
element.setAttribute( 'data-background-hash', data.background +
data.backgroundSize +
data.backgroundGradient +
data.backgroundImage +
data.backgroundVideo +
data.backgroundIframe +
Expand All @@ -1218,6 +1220,7 @@
if( data.backgroundTransition ) element.setAttribute( 'data-background-transition', data.backgroundTransition );

// Background image options are set on the content wrapper
if (data.backgroundGradient) contentElement.style.backgroundImage = data.backgroundGradient;
if( data.backgroundSize ) contentElement.style.backgroundSize = data.backgroundSize;
if( data.backgroundRepeat ) contentElement.style.backgroundRepeat = data.backgroundRepeat;
if( data.backgroundPosition ) contentElement.style.backgroundPosition = data.backgroundPosition;
Expand Down
Loading