Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<title>Star Wars Spoilers</title>
	<link href="https://fonts.googleapis.com/css?family=Nunito" rel="stylesheet">
</head>

<body>
	<div role="main">
		<img src="https://svgshare.com/i/AG3.svg" alt="" />
		<h1 tabindex="0">Star Wars Spoilers</h1>
		<div class="spoiler-group">
			<p class="spoiler">
				<span tabindex="0">Darth Vader is Luke Skywalker's Father! Noooooooooooo!</span>
			</p>
			<p class="spoiler">
				<span tabindex="0">Jar Jar Binks is Sith!</span>
			</p>
			<p class="spoiler">
				<span tabindex="0">I had friends on that Death Star :(</span>
			</p>
			<p class="spoiler">
				<span tabindex="0">Kylo Ren is ripped <br> and has an eight pack!</span>
			</p>
			<p class="spoiler">
				<span tabindex="0">Anakin Skywalker hates sand. It's course. And gets everywhere.</span>
			</p>
			<p class="spoiler">
				<span tabindex="0">'Do or do not. There is no try.' - Yoda</span>
			</p>
			<p class="spoiler">
				<span tabindex="0">Han shot first.</span>
			</p>
			<p class="spoiler">
				<span tabindex="0">'Beep boop. Boop Beep.' - Artoo</span>
			</p>
			<p class="spoiler">
				<span tabindex="0">Boba Fett survived the Sarlacc pit.</span>
			</p>
			<p class="spoiler">
				<span tabindex="0">Droids don't rip your arms off when they lose.</span>
			</p>
			<p class="spoiler">
				<span tabindex="0">It was indeed no moon. It was a space station. </span>
			</p>
			<p class="spoiler">
				<span tabindex="0">Captain Phasma's chromium armor is made from emporer Palpatine's Yacht.</span>
			</p>
			<p class="spoiler">
				<span tabindex="0">Those really were the droids they were looking for.</span>
			</p>
			<p class="spoiler">
				<span tabindex="0">'Nrgggh arwghhhh nrghh' - Chewbacca</span>
			</p>
			<p class="spoiler">
				<span tabindex="0">Someone is bound to have a bad feeling about this.</span>
			</p>
			<p class="spoiler">
				<span tabindex="0">This isn't going to go the way you think.</span>
			</p>
			<p class="spoiler">
				<span tabindex="0">'Hello There!' - Ben Kenobi</span>
			</p>
			<p class="spoiler">
				<span tabindex="0">Han won the Millenium Falcon<br>fair and square!</span>
			</p>
			<p class="spoiler">
				<span tabindex="0">Darth Maul survived being cut in half by Obi-Wan on Naboo.</span>
			</p>
		</div>
		<div class="controls"></div>
	</div>
<script
  src="https://code.jquery.com/jquery-3.3.1.min.js"
  integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
  crossorigin="anonymous"></script>
</body>

</html>
              
            
!

CSS

              
                body {
  background: rgb(47, 84, 141) url(https://svgshare.com/i/AF4.svg) repeat 0 0;
  background-size: 400px auto;
  font-family: "Nunito", sans-serif;
}

img {
  display: block;
  width: 150px;
  margin: 100px auto;
  cursor: pointer;
}

.spoiler {
  background: #1d3c6a;
  max-width: 440px;
  width: 100%;
  margin: 0 auto 20px;
  border-radius: 5px;
  text-align: center;
  font-size: 1.5em;
}


.spoiler span {
  color: #F0F0F0;
  display: block;
  padding: 40px 20px;
}

button,
.show-more {
  background: #F0F0F0;
  border: none;
  border-radius: 5px;
  color: #1d3c6a;
  font-size: 1em;
  max-width: 440px;
  width: 100%;
  padding: 40px 0;
  cursor: pointer;

}

.show-more {
  font-size: 1.5em;
  background: #328adb;
  margin: 0 auto 20px;
  text-align: center;
  color: #F0F0F0;
}

button:hover,
button:focus {
  background: #cbd1d4;
}

.show-more:hover,
.show-more:focus {
  background: #327cc0;
}

.jakku button {
  color: #844B00;
  background: #CCA556;
}

.jakku button:hover,
.jakku button:focus {
  background: #cfa143;
}

.jakku .spoiler {
  background: #C57002;
}

.jakku .show-more,
.jakku h1 {
  background: #ad7935;
}

.jakku .show-more:hover,
.jakku .show-more:focus {
  background: #d1984e;
}

h1 {
  font-size: 2em;
  background: #328adb;
  margin: 0 auto 20px;
  text-align: center;
  color: #F0F0F0;
  border: none;
  border-radius: 5px;
  max-width: 440px;
  width: 100%;
  padding: 40px 0;
}
              
            
!

JS

              
                const $reveal = $('<button>Reveal Spoiler</button>');
const $showMore = $('<p class="show-more" tabindex="0" role="button">Show More</p>');

$.fn.randomise = function (selector) {
    (selector ? this.find(selector) : this.parent().each(function () {
        $(this).children(selector).sort(function () {
            return Math.random() - 0.5;
        }).detach().appendTo(this);
    }))
    return this;
};

$('.spoiler').randomise();
$('.spoiler').append($reveal);
$('.spoiler span').hide();
$('.spoiler').on('click', 'button', function (event) {
    $(this).prev().show().focus();
    $(this).hide();
});

const $img = $('img');
$img.on('click', function (event) {
    if ($(this).attr('src') == `https://svgshare.com/i/AG3.svg`) {
        $(this).hide().attr('src', `https://svgshare.com/i/AEV.svg`).fadeIn();
        $('body').addClass('jakku');
        $('body').css('background', 'rgb(227, 200, 141) url("https://svgshare.com/i/AFh.svg") repeat scroll 0px 0px / 400px padding-box border-box');
    } else {
        $(this).hide().attr('src', `https://svgshare.com/i/AG3.svg`).removeAttr('style').fadeIn();
        $('body').removeClass().removeAttr('style');
    }
});

$('.spoiler').hide();
$('.spoiler:lt(3)').show();
$('.controls').append($showMore);
const $spoilersTotal = $('.spoiler').length;
let $spoilersShown = $('.spoiler:visible').length;
$('.show-more').on('keypress click', function (event) {
    if(a11yClick(event) === true){
        $spoilersShown += 3;
        if ($spoilersShown >= $spoilersTotal) {
            $(`.spoiler:lt(${$spoilersTotal})`).slideDown();
            $([document.documentElement, document.body]).animate({
                scrollTop: $(`.spoiler-group .spoiler:nth-of-type(${$spoilersShown -2}) button`).offset().top
            })
            $(this).hide();
            $(`.spoiler-group .spoiler:nth-of-type(${$spoilersShown -2}) button`).focus();
            $spoilersShown = $spoilersTotal;
        } else {
            $(`.spoiler:lt(${$spoilersShown})`).slideDown();
            $(`.spoiler-group .spoiler:nth-of-type(${$spoilersShown -2}) button`).focus();
            $([document.documentElement, document.body]).animate({
                scrollTop: $(`.spoiler-group .spoiler:nth-of-type(${$spoilersShown -2}) button`).offset().top
            })
        }
    }
})

function a11yClick(event){
    if(event.type === 'click'){
        return true;
    }
    else if(event.type === 'keypress'){
        var code = event.charCode || event.keyCode;
        if((code === 32)|| (code === 13)){
            return true;
        }
    }
    else{
        return false;
    }
}
              
            
!
999px

Console