Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ 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

Auto Save

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

              
                <div class="comic-navigation contrast">
	<nav class="comic-navigation__list" aria-label="comic navigation"><a href="https://tavern-wenches.com/comic/unexpected-results/" aria-label="First Comic" class="comic-navigation__link first"><span>First <span class="sr-only">Comic</span></span></a>
		<a href="https://tavern-wenches.com/comic/not-lucky/" aria-label="Previous Comic" class="comic-navigation__link prev"><span>Prev <span class="sr-only">Comic</span></span></a>
		<span class="comic-navigation__item current" aria-hidden="true">Page 22</span>
		<span class="comic-navigation__link next disabled"><span>Next <span class="sr-only">Comic</span></span></span>
		<span class="comic-navigation__link last disabled"><span>Last <span class="sr-only">Comic</span></span></span></nav>
</div>
<article class="comic">
	<div class="comic__page container page">
		<button class="btn comic_cc">Toggle CC</button>
		<header class="comic__header">
			<h1 class="comic__header__title">Improvised Weapon</h1>
			<a class="comic__header__author" rel="author" rel="noopener" href="https://tavern-wenches.com/comic/improvised-weapon/" target="_blank">
				S Frisk
			</a>
		</header>
		<div class="comic__row">
			<div class="comic__panel ">
					<div class="comic__panel__img">
					<img src="https://assets.codepen.io/198554/wenches-022-a.jpg" class="comic__panel__image" alt="Panel 1: Thog and Xavros are walking down a path in the middle of the night.  Both are wearing backpacks carrying their supplies. Thog is facing to the right as he walks down the road, carrying an unconscious Horbin in his arms, with a small pack hanging off his left arm. Xavros is slightly ahead of Thog, turning to look down at the sleeping Horbin.

&quot;Awww,&quot; exclaims Xavros. &quot;Horbin looks so peaceful when he's sleeping.&quot;" >
				</div>
				
				<div class="comic__script">
					<div class="comic__script__content">
						<p><strong>Xavros</strong>: Awww, Horbing looks so peaceful when he's sleeping</p>
					</div>
				</div>
			</div>
			<div class="comic__panel ">
									<div class="comic__panel__img">


					<img src="https://assets.codepen.io/198554/wenches-022-b.jpg" class="comic__panel__image" alt="Panel 2: Thog and Xavros and walking down a path. Behind them in the distance, the lighthouse ca be seen standing at the top of a hill.  A tree is to their left, with an old wooden sign on the right.  From the forward view, more of what Thog is carrying can be seen, including a variety of javelins that seemed to be strapped to the back of his bag.  Two small axes are hanging  out ot either side of his bag, with a much larger greataxe extending to the right behind Xavros's head.

Thog is looking down at Horbin in his hands, who is passed out, his mouth open wide as if mid snore. 

&quot;Thog prefers to hold a weapon while traveling,&quot; Thog says.

Xavros looks away from the two, rolling his eyes.  &quot;I told you, Thog,&quot; says Xavros, &quot;You can't drag him behind us using your fifty feet of rope.&quot" >
				</div>
				<div class="comic__script">
					<div class="comic__script__content">
						<p><strong>Thog</strong>: Thog prefers to hold a weapon while traveling.</p>
						<p><strong>Xavros</strong>: I told you, Thog, you can't drag him behind us using your fifty feet of rope.</p>
					</div>
				</div>
			</div>
			<div class="comic__panel ">
									<div class="comic__panel__img">


					<img src="https://assets.codepen.io/198554/wenches-022-c.jpg" class="comic__panel__image" alt="Panel 3: A full body view of Thog and Xavros walking to the right down a grassy path.  Behind them is a wooden sign with arrows pointing back towards the lighthouse and away from it.  Beyond them a body of water can be seen, with a few rocks jutting out above the surface.\
\
&quot;Thog will not be able to protect Xavros if there is an encounter,&quot; says Thog.

Xavros turns back to face his fellow party member. &quot;I can cast firebolt you know,&quot; says Xavros." >
				</div>
				
				<div class="comic__script">
					<div class="comic__script__content">
						<p><strong>Thog</strong>: Thog will not be able to protect Xavros if there is an encounter.</p>
						<p><strong>Xavros</strong>: I can cast firebolt you know.</p>
					</div>
				</div>
			</div>
		</div>
		<div class="comic__row">
			<div class="comic__panel ">
									<div class="comic__panel__img">


					<img src="https://assets.codepen.io/198554/wenches-022-d.jpg?" class="comic__panel__image" alt="Panel 4: Thog and Xavros walk down a path, the lighthouse in the distance behind him. Thog looks down at Horbin in his arms, a raised eyebrow and a thoughtful expression on his face.

&quot;Thog could use halfling as an improvised weapon,&quot; says Thog.

Xavros looks over at Thog, a skeptical expression on his face." >
				</div>
				<div class="comic__script">
					<div class="comic__script__content">
						<p><strong>Thog</strong>: Thog could use halfling as an improvised weapon.</p>
					</div>
				</div>
			</div>
			<div class="comic__panel ">
									<div class="comic__panel__img">


					<img src="https://assets.codepen.io/198554/wenches-022-e.jpg" class="comic__panel__image" alt="Panel 5: Close up of Xavros laughing. His hand is resting on Thog's shoulder, who is partially off panel, who looks over at Xavros.

&quot;You're really quite the jokester for a half-orc, Thog,&quot; Xavros laughs." >
				</div>
				
				<div class="comic__script">
					<div class="comic__script__content">
						<p><strong>Xavros</strong>: You're really quite the jokester for a half orc, Thog.</p>
					</div>
				</div>
			</div>
			<div class="comic__panel ">
									<div class="comic__panel__img">


					<img src="https://assets.codepen.io/198554/wenches-022-f.jpg" class="comic__panel__image" alt="Panel 6: Close up of Thog's face a black background behind him. He is looking to the right, where Xavros is off panel.

&quot;Thog not,&quot; Thog begins.  However, whatever he was going to say is cut off.

&quot;Well, howdy there, strangers,&quot; says an unknown voice coming from off panel to the right." >
				</div>
				
				<div class="comic__script">
					<div class="comic__script__content">
						<p><strong>Thog</strong>: Thog not . . .</p>
						<p><strong>Unknown Voice</strong>: Well, howdy there, strangers.</p>
					</div>
				</div>
			</div>
		</div>
		<div class="comic__meta">
			<time datetime="{{.Date.Format "2006-01-02"}}">Sep 28, 2020</time>
		</div>
	</div>
</article>
              
            
!

CSS

              
                $bp_xs: 400px;
$bp_sm: 550px;
$bp_md: 768px;
$bp_lg: 1100px;
$bp_xl: 1400px;
$bp_xxl: 2400px;

$serif: 'Libre Baskerville', serif;
$sans-serif: 'Source Sans Pro', sans-serif;

:root {
  --white: #fbf8f9;
  --black: #010101;

  --accent-800: #491f2f;
  --accent-600: #6D2E46;
  --accent-500: #794056;
  --accent-400: #926274;
  --accent-300: #b4939f;
  --accent-100: #dfd0d5;

  --secondary-600: #CEBEBE;
  --secondary-300: #ECE2D0;
  
  // opaque greys
  --grey-800:   #0e0d0d;
  --grey-700:   #333233;
  --grey-600:   #656464;
  --grey-500:   #979596;
  --grey-400:   #c9c7c7;
  --grey-300:   #d6d3d4;
  --grey-200:   #e2dfe0;
  --grey-100:   #efeced;

  --black-trans-800: rgba(1,1,1,0.95);
  --black-trans-700: rgba(1,1,1,0.8);
  --black-trans-600: rgba(1,1,1,0.6);
  --black-trans-500: rgba(1,1,1,0.4);
  --black-trans-400: rgba(1,1,1,0.2);
  --black-trans-300: rgba(1,1,1,0.15);
  --black-trans-200: rgba(1,1,1,0.1);
  --black-trans-100: rgba(1,1,1,0.05);

  --white-trans-800: rgba(251,248,249,0.95);
  --white-trans-700: rgba(251,248,249,0.8);
  --white-trans-600: rgba(251,248,249,0.6);
  --white-trans-500: rgba(251,248,249,0.4);
  --white-trans-400: rgba(251,248,249,0.2);
  --white-trans-300: rgba(251,248,249,0.15);
  --white-trans-200: rgba(251,248,249,0.1);
  --white-trans-100: rgba(251,248,249,0.05);

  --purple:     #8a53b0;
  --grey-blue:  #7e88b7;
  --blue:       #73cde5;
  --sea-green:  #4b9482;
  --green:      #588237;
  --yellow:     #d7bd54;
  --orange:     #af8229;
  --red:        #974c4b;
}

:root {
  --accentColor: var(--accent-600);
  --secondaryColor: var(--secondary-300);
  --html-bg: var(--white);
  --btn-color: var(--white);
  --btn-bg: var(--accentColor);
  --btn-bg__hover: var(--accent-400);
  --btn-bg__focus: var(--accent-300);
  --btn-border: var(--accentColor);
  --site-bg: var(--black-trans-100);
  --site-text-color: var(--black);
  --site-heading-color: var(--accentColor);
  --site-link-color: var(--accentColor);
  --site-link-border: linear-gradient(to right, var(--black) 50%, transparent 50%), linear-gradient(to right, var(--black) 50%, transparent 50%), linear-gradient(to bottom, var(--black) 50%, transparent 50%), linear-gradient(to bottom, var(--black) 50%, transparent 50%);
  --site-link-border__contrast: linear-gradient(to right, var(--white-trans-600) 50%, transparent 50%), linear-gradient(to right, var(--white-trans-600) 50%, transparent 50%), linear-gradient(to bottom, var(--white-trans-600) 50%, transparent 50%), linear-gradient(to bottom, var(--white-trans-600) 50%, transparent 50%);

  --comic-bg: var(--white);
  --comic-panel-bg: var(--white-trans-100);
  --comic-nav-bg: var(--accentColor);
  --comic-nav-link-color: var(--white);
  --comics-nav-active-bg: var(--accentColor);
  --comics-nav-active-color: var(--white);
  --comic-img-bg: var(--secondary-600);

  @media (prefers-color-scheme: dark) {
    --accentColor: var(--accent-100);
    --html-bg: var(--accent-600);
    --site-bg: var(--black-trans-600);
    --site-link-border: linear-gradient(to right, var(--white-trans-800) 50%, transparent 50%), linear-gradient(to right, var(--white-trans-800) 50%, transparent 50%), linear-gradient(to bottom, var(--white-trans-800) 50%, transparent 50%), linear-gradient(to bottom, var(--white-trans-800) 50%, transparent 50%);
    --site-link-border__contrast: linear-gradient(to right, var(--white-trans-600) 50%, transparent 50%), linear-gradient(to right, var(--white-trans-600) 50%, transparent 50%), linear-gradient(to bottom, var(--white-trans-600) 50%, transparent 50%), linear-gradient(to bottom, var(--white-trans-600) 50%, transparent 50%);

		--btn-bg: var(--accent-600);
    --btn-border: var(--accent-600);
    --comics-archive-bg: var(--white-trans-100);
    --comic-img-bg: var(--accentColor);
    --comic-panel-bg: var(--black-trans-100);
  }
}



html {
	margin: 0;
	padding: 0;
	font-size: 1em;
	box-sizing: border-box;
  height: 100%;
  font-family: $sans-serif;
	line-height: 1.15;
	background: var(--html-bg);
}

*, *:before, *:after {
	box-sizing: border-box;
}

body {
	margin: 0;
	padding: 0;
	font-weight: 400;
	line-height: 1.45;
  color: var(--site-text-color);
  background: var(--site-bg);
	display: grid;
	min-height: 100%;
  grid-template-rows: 1fr auto;
	font-size: 1rem;
	padding-bottom: 0px;
}

html {font-size: 100%;} /*16px*/

body {
  font-family: $sans-serif;
  font-weight: 400;
  line-height: 1.65;
}

img {
	max-width: 100%;
	height: auto;
}


.focusable {
	display: inline-block;
	line-height: 0; // this prevents a weird margin under the textarea
}

a:focus,
button:focus,
input:focus,
.focusable:focus-within {
  position: relative;
  outline: 0;
  &::after {
    content: '';
    display: block;
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background-image: var(--site-link-border);
    background-size: 10px 2px, 10px 2px, 2px 10px, 2px 10px;
    background-position: 0 0, 0 100%, 0 0, 100% 0;
    background-repeat: repeat-x, repeat-x, repeat-y, repeat-y;
    animation: marching-ants 2s;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
  }
}


h1, h2, h3, h4, h5, h6 {
	margin: 2rem 0 1rem;
	@media (min-width: $bp_md) {
		margin: 2.75rem 0 1.05rem;
	}
	font-family: $serif;
	color: var(--site-heading-color);
  font-weight: 400;
	line-height: 1.15;
}

h1 {
	margin-top: 0;
  font-size: 1.866em;
	font-weight: bold;
	font-variant: small-caps;
	letter-spacing: 2px;
	@media (min-width: $bp_md) {
		font-size: 2.488em;
	}
}

a {
	color: var(--site-link-color);
}

.contrast {
  a:focus,
  button:focus,
  input:focus,
  .focusable:focus-within {
    &::after {
      background-image: var(--site-link-border__contrast);
    }
  }
}

@keyframes marching-ants {
  0% {
    background-position: 0 0,  0 100%,  0 0,  100% 0;
  }
  100% {
    background-position: 20px 0, -20px 100%, 0 -20px, 100% 20px;
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  -webkit-clip-path: inset(50%);
  clip-path: inset(50%);
  border: 0;
}

.hidden {
	display: none;
}

.container {
  margin: 0 1em;
  width: auto;
  @media (min-width: $bp_md) {
    margin: 0 2em;
  }
  @media (min-width: $bp_xl) {
    margin: 0 auto;
    max-width: calc(1300px - 2em);
  }
}

.btn {
  display: inline-block;
  font-family: $sans-serif;
  font-weight: 400;
  font-size: 1rem;
	margin: .5em 0;
  color: var(--btn-color);
  text-align: center;
  vertical-align: middle;
  user-select: none;
  background-color: var(--btn-bg);
  border: 1px solid var(--btn-border);
  text-decoration: none;
  padding: .25em;
  text-transform: uppercase;
  letter-spacing: .5px;
  border-radius: 3px;
  &:hover {
    background: var(--btn-bg__hover);
  }
  &:active, &:focus{
    background: var(--btn-bg__focus);
  }
}


.comic {
	margin: 3em 0;
	@media (min-width: $bp_md) {
		margin: 3em 1em;
	}
	@media (min-width: $bp_lg) {
		margin: 3em auto;
  }
  &__navigation-notes {
    display: none;
    @media (min-width: $bp_md) {
      display: block;
      text-align: center;
      font-style: italic;
    }
  }
  &__page {
    background: var(--comic-bg);
    padding: 2em;
  }
	&__header {
		padding: 1em 0;
		text-align: center;
		@media (min-width: $bp_md) {
			display: flex;
			justify-content: space-between;
			align-items: flex-end;
			padding: .5em;
		}
		&__title {
			font-size: 1em;
      padding-bottom: 1em;
      margin-bottom: 0;
			@media (min-width: $bp_md) {
				padding-bottom: 0;
			}
		}
	}
	&__row {
		margin: 0 -1em;
		@media (min-width: $bp_md) {
			display: flex;
			margin: 0;
			justify-content: center;
		}
	}
	&__panel {
		padding: 3em 0;
		text-align: center;
		@media (min-width: $bp_md) {
			padding: .5em;
			height: auto;
			display: block;
		}
		&__image {
			background: var(--comic-panel-bg);
			max-width: 100%; 
			max-height: 500px;
			width: auto;
			height: auto;
			@media (min-width: $bp_md) {
				max-width: 100%;
				height: auto;
				max-height: inherit;
			}
      &-mobile {
        max-height: inherit;
        max-width: 100%;
      }
		}
	}
	&__footer {
		&__image {
			@media (min-width: $bp_md) {
				display: none;
			}
		}
	}
	&__meta {
		display: flex;
		align-items: flex-start;
		justify-content: space-between;
		padding: 1em .5em;
		align-items: center;
		time {
			line-height: 1em;
		}
		@media (min-width: $bp_md) {
			padding: 0 .5em 1em;
		}
	}
	&__load-more {
    height: 200px;
    background: var(--comic-load-more-bg);
    color: var(--comic-load-more-color);
		display: flex;
		flex-direction: column;
		align-items: center;
    justify-content: center;
    padding-bottom: 4em;
		transition: color .25s linear, background .25s linear; 
		@media (min-width: $bp_md) {
			display: none;
		}
		svg {
      margin: 1em;
      fill: currentColor;
			transition: fill .25s linear; 
		}
		&.active {
			color: var(--comic-load-more-color__active);
		}
		&.hidden {
			display: none;
		}
	}
  &__content {
    padding: 1em 0;
    @media (min-width: $bp_md) {
      padding: 2em 2em 2em 0;
      grid-column-start: 1;
      grid-column-end: span 8;
      grid-row-start: 1;
    }
	}
	
	&__script {
		display: none;
	}
	&.cc {
		.comic {
			&__script {
				display: block;
				text-align: left;
				font-size: 1.5em;
				@media (min-width: $bp_md) {
					border-left: 1px solid var(--accent-300);
					font-size: 2em;
					padding-left: 1em;
				flex: 1;
				}
			}
			&__row {
				@media (min-width: $bp_md) {
					display: block;
				}
			}
			&__panel {
				border: 1px solid var(--black-trans-300);
				padding: 1em;
				margin: 1em 0;
				background: var(--black-trans-100);
				@media (min-width: $bp_md) {
					display: flex;
				}
				&__img {
					flex: 1;
				}
				img {
					@media (min-width: $bp_md) {
						max-width: 100%;
						height: auto;
						width: auto;
						padding-right: 1em;
					}
					
				}
			}
		}
		
	}
}

.comic-navigation {
	position: sticky;
	top: 0;
	width: 100%;
  padding: .5em 1em;
  background: var(--comic-nav-bg);
  z-index: 10000;
  box-shadow: 0 .4em .4em var(--site-header-shadow); 
  @media (min-width: $bp_md) {
		background: var(--comic-nav-bg);
  }
  &__list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 35em;
    margin: 0 auto;
    color: var(--comic-nav-link-color);
  } 
  &__item {
    &.current {
      text-align: center;
      width: 40%;
      font-size: .9em;
      font-family: $serif;
      letter-spacing: 2px;
      font-variant: small-caps;
      font-weight: bold; 
      @media (min-width: $bp_md) {
        font-size: 1em;
      }
    }
  } 
  &__link {
    display: inline-flex;
    align-items: center;
    color: var(--comic-nav-link-color);
    text-decoration: none;
    span {
      display: none;
      @media (min-width: $bp_md) {
        display: inline-block;
      }
    }
    svg {
      margin: .5em;
      fill: var(--comic-nav-link-color);
    }
    &:hover,
    &:focus {
      opacity: .75;
    }
    &.disabled {
      opacity: .65;
    }
  }
}

              
            
!

JS

              
                /**
The following pen is a comic page with the following features:

* Fully responsive. Switching to mobile sizes will stack the comic vertically
* Screen reader accessible with descriptive alt text of each panel
* CC Mode that will provide the reader with a large copy of the text they can read in a sans-serif font.


Update: I now have this working oon my website, along with the ability to adjust closesd caption settings!

Check it out at https://tavern-wenches.com/settings/#settings

**/

const ccBtn = document.querySelector('.comic_cc');
const comic = document.querySelector('.comic')

let ccBtnOn = false;

ccBtn.addEventListener("click", (event) => {
	ccBtnOn ? comic.classList.remove('cc') : comic.classList.add('cc');
	ccBtnOn = !ccBtnOn
})
              
            
!
999px

Console