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

              
                <body class="red-and-black">
	
	<!-- Featured Image	 -->
	
	<h2>Featured image</h2>
	<div class="js-module u-flex u-width-600 u-margin-t-40">
		<div class="site-featured-image u-width-600">
			<figure class="post-thumbnail a-filter-child-img">
				<img src="http://localhost/c4aa/wp-content/uploads/2020/02/IMG_6019-1568x701.jpg" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="" srcset="http://localhost/c4aa/wp-content/uploads/2020/02/IMG_6019-1568x701.jpg 1568w, http://localhost/c4aa/wp-content/uploads/2020/02/IMG_6019-580x259.jpg 580w, http://localhost/c4aa/wp-content/uploads/2020/02/IMG_6019-1400x626.jpg 1400w, http://localhost/c4aa/wp-content/uploads/2020/02/IMG_6019-768x343.jpg 768w, http://localhost/c4aa/wp-content/uploads/2020/02/IMG_6019-1536x687.jpg 1536w, http://localhost/c4aa/wp-content/uploads/2020/02/IMG_6019-2048x915.jpg 2048w" sizes="(max-width: 1568px) 100vw, 1568px" width="1568" height="701">					
			</figure>
			<div class="entry-header">		
				<h1 class="entry-title">image filters test</h1>
			</div><!-- .entry-header -->
		</div>
		<div class="js-button-container u-flex u-flex-direction-column">
			<button class="beige-and-red">beige-and-red</button>
			<button class="red-and-black">red-and-black</button>
			<button class="beige-and-black">beige-and-black</button>
			<button class="beige-and-grey">beige-and-grey</button>
			<button class="beige-and-grey-vintage">beige-and-grey-vintage</button>
</div>
	</div>
	
	
	<!-- Image Block	 -->
	
	<h2>Inline block images</h2>
	<div class="js-module u-width-600 u-flex">
		<div class="a-filter-child-img">
			<img src="https://live.staticflickr.com/1960/45670544451_05dbf59644_n.jpg" alt="">
		</div>
		<div class="js-button-container u-flex u-flex-direction-column">
			<button class="beige-and-red">beige-and-red</button>
			<button class="red-and-black">red-and-black</button>
		<button class="beige-and-black">beige-and-black</button>
			<button class="beige-and-grey">beige-and-grey</button>
			<button class="beige-and-grey-vintage">beige-and-grey-vintage</button>
		</div>
	</div>
	<div class="js-module u-width-600 u-flex u-margin-t-40">
		<div class="a-filter-child-img">
			<img src="https://live.staticflickr.com/4754/26537562208_100527f564.jpg" alt="">
		</div>
		<div class="js-button-container u-flex u-flex-direction-column">
			<button class="beige-and-red">beige-and-red</button>
			<button class="red-and-black">red-and-black</button>
		<button class="beige-and-black">beige-and-black</button>
			<button class="beige-and-grey">beige-and-grey</button>
			<button class="beige-and-grey-vintage">beige-and-grey-vintage</button>
		</div>
	</div>

	
	<!-- Cover Block	 -->

	<h2>WP cover block</h2>
	<div class="js-module u-flex u-width-600 u-margin-t-40">
		<div class="a-filter-cover-img wp-block-cover has-background-dim-30 has-background-dim" style="background-image:url(http://backtobasics.c4aa.org/wp-content/uploads/2019/05/NYC_Brooklyn_Musum_OSF_Arts_Exchange_SCA_2NYC_Met_Museum_NY_OSF_SCA_201804-8381.jpg)"><div class="wp-block-cover__inner-container">
		<p class="has-text-align-center has-huge-font-size"> The C4AA offers training, advising, research, and resources.</p>
	</div>	
		
	</div>
		<div class="js-button-container u-flex u-flex-direction-column">
			<button class="beige-and-red">beige-and-red</button>
			<button class="red-and-black">red-and-black</button>
		<button class="beige-and-black">beige-and-black</button>
			<button class="beige-and-grey">beige-and-grey</button>
			<button class="beige-and-grey-vintage">beige-and-grey-vintage</button>
		</div>
	</div>
</body>
              
            
!

CSS

              
                
/* Duotone Defaults */
:root {
	--color-brandBeige: #f2f1ed; /* Fallback */
	--color-brandBeige: hsla(48, 16%, 94%, 1);
	--color-brandBlack: #292724; /* Fallback */
	--color-brandBlack: hsla(36, 6%, 5%, 0.9);
	--color-brandBlue: #005eb8; /* Fallback */
	--color-brandBlue: hsla(209, 100%, 34%, 0.9);
	--color-brandGrey: #7b736c; /* Fallback */
	--color-brandGrey: hsla(28, 6%, 42%, 0.9);
	--color-brandRed: #da2f3b; /* Fallback */
	--color-brandRed: hsla(356, 80%, 45%, 0.9);
	--color-brandWhite: #fafaf9; /* Fallback */
	--color-brandWhite: hsla(60, 9%, 98%, 0.9);
	--color-brandYellow: #e1cd00; /* Fallback */
	--color-brandYellow: hsla(55, 100%, 46%, 0.9);

	/* Default Colors */
	--duotone-default-base: var(--color-brandBeige);
	--duotone-default-foreground: var(--color-brandRed);

	/* Default Image Treatment */
	--duotone-base: var(--duotone-default-base);
	--duotone-bg-blend: multiply;
	--duotone-blur: 0px;
	--duotone-fg-blend: screen;
	--duotone-foreground: var(--duotone-default-foreground);
	--duotone-opacity: 1;
	--duotone-spacing: 1%;
}

.a-filter-child-img {
	background-color: var(--duotone-base);
	overflow: hidden;
	padding: var(--duotone-spacing);
	position: relative;
	transition: background-color 250ms ease;
}

.a-filter-child-img img {
	filter: grayscale(100%) contrast(1) blur(var(--duotone-blur));
	mix-blend-mode: var(--duotone-bg-blend);
	object-fit: cover;
	opacity: var(--duotone-opacity);
	position: relative;
	width: 100%;
	transition: mix-blend-mode filter opacity 250ms ease-in-out;
}

.a-filter-child-img::before {
	background-color: var(--duotone-foreground);
	bottom: 0;
	content: "";
	height: 100%;
	left: 0;
	mix-blend-mode: var(--duotone-fg-blend);
	position: absolute;
	right: 0;
	top: 0;
	width: 100%;
	z-index: 1;
}

/* Hover state */

.a-filter-child-img:hover {
	background-color: initial;
	opacity: 1;
}

.a-filter-child-img:hover::before {
	background-color: initial;
}

.a-filter-child-img:hover img {
	filter: none;
	mix-blend-mode: normal;
	opacity: 1;
}

/* Themes */

.red-and-black {
	--duotone-base: var(--color-brandRed);
	--duotone-foreground: var(--color-brandBlack);
	--duotone-bg-blend: multiply;
	--duotone-fg-blend: screen;
	--duotone-opacity: 0.96;
}

.beige-and-black {
	--duotone-base: var(--color-brandBeige);
	--duotone-foreground: var(--color-brandBlack);
	--duotone-bg-blend: multiply;
	--duotone-fg-blend: lighten;
	--duotone-opacity: 1;
}

.beige-and-red {
	--duotone-base: var(--color-brandBeige);
	--duotone-foreground: var(--color-brandRed);
	--duotone-bg-blend: multiply;
	--duotone-fg-blend: screen;
	--duotone-opacity: 1;
}

.beige-and-grey {
	--duotone-base: var(--color-brandBeige);
	--duotone-foreground: var(--color-brandGrey);
	--duotone-bg-blend: multiply;
	--duotone-fg-blend: screen;
	--duotone-opacity: 1;
}

.beige-and-grey-vintage {
	--duotone-base: var(--color-brandBeige);
	--duotone-foreground: var(--color-brandBlack);
	--duotone-bg-blend: color-burn;
	--duotone-fg-blend: screen;
	--duotone-opacity: 0.69;
}

/* Utils */

button {
	white-space: nowrap;
}

.u-width-600 {
	width: 600px;
}

.u-flex {
	display: flex;
}

.u-flex-direction-column {
	flex-direction: column;
}

.u-margin-t-40 {
	margin-top: 40px;
}

/* Basic WP cover block styles */

.wp-block-cover {
	background-attachment: fixed;
	color: white;
}

.wp-block-cover.has-background-dim::before {
	content: "";
	position: absolute;
	top: 0;
	left: 0;
	bottom: 0;
	right: 0;
	background-color: inherit;
	opacity: 0.5;
	z-index: 1;	
}

.wp-block-cover__inner-container {
	z-index: 1;	
}

.wp-block-cover {
	background-color: #000;
	position: relative;
	background-size: cover;
	background-position: 50%;
	min-height: 430px;
	width: 100%;
	margin: 0 0 1.5em;
	display: flex;
	justify-content: center;
	align-items: center;
	overflow: hidden;
}

.a-filter-cover-img {
	background-color: var( --duotone-base );
	background-blend-mode: var( --duotone-bg-blend );
/* 	Could do stuff like this: */
/* 	filter: grayscale(30%) sepia(30%) contrast(2) brightness(1.5); */
}

.a-filter-cover-img::before {
	background-color: var( --duotone-foreground ) !important;
}


/* Misc */

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

JS

              
                document.querySelectorAll( '.js-module' ).forEach( ( el ) => {
	let btnListener = el.querySelector( '.js-button-container' );

	btnListener.addEventListener( 'click', ( e ) => {
		
		if ( e.target.nodeName == 'BUTTON' ) {
			if ( el.querySelector( '.a-filter-child-img' ) ) {
				el.querySelector( '.a-filter-child-img' ).setAttribute( 'class', 'a-filter-child-img ' + e.target.textContent );
			}
			
			if ( el.querySelector( '.a-filter-cover-img' ) ) {
				el.querySelector( '.a-filter-cover-img' ).setAttribute( 'class', 'wp-block-cover wp-block-cover has-background-dim a-filter-cover-img ' + e.target.textContent );
			}
		}
	});
})
              
            
!
999px

Console