cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

Looking for quick-add? Try the external resource search, it's quicker and gives you access to the most recent version of thousands of libraries. ☝️

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Looking for quick-add? Try the external resource search, it's quicker and gives you access to the most recent version of thousands of libraries. ☝️

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

            
              .headline
	input(
		type='text'
		name='headline'
		placeholder='new'
		maxlength='7'
		class='c-input-headline'
		id='is-headline'
	)
span.c-block
#is-duplicate.c-input-headline.u-hidden
            
          
!
            
              :root {
	// COLOR CSS VARIABLES
	--color_txt: #090707; // Black
	--color_base: #fff; // White
	--color_block: #e8e8e8; // Grey
	--color_accent: #ff1d8e; // Neon Pink
	--color_marker: #c9ff42; // Neon Yellow

	// SIZE CSS VARIABLES
	--font_size: 10em; // Resize headline by only editing this variable
	--height: calc(var(--font_size) * 1.35);
}

// MIXINS
@mixin size($w, $h: $w) {
	width: $w;
	height: $h;
}

// LAYOUT
body {
	background-color: var(--color_base);
}

::placeholder {
	color: var(--color_txt);
	opacity: 1; // Needed for Firefox
}

::selection {
	background-color: var(--color_marker);
}

// HEADLINE WRAPPER
.headline {
	@include size(100%, var(--height));
	margin-top: 10%;
	text-align: center;
	overflow: hidden;
}

// HEADLINE INPUT FIELD
// HEADLINE DUPLICATE
.c-input-headline {
	@include size(100%);
	border: 0;
	background-color: transparent;
	caret-color: var(--color_accent); // Not supported yet in Safari or IE
	color: var(--color_txt);
	display: inline-block; // Needed to get precise text width
	font-family: "Oswald", sans-serif;
	font-size: var(--font_size);
	letter-spacing: 0.02em;
	margin: 0;
	padding: 0;
	text-align: center;
	text-transform: uppercase;
	clip-path: polygon(100% 10%, -112% 100%, 100% 90%); // Not supported yet in IE

	&:focus {
		outline: none;
	}
}

// BACKGROUND IMG BLOCK
.c-block {
	@include size(47vw, 100vh);
	background-color: var(--color_block);
	background-image: url('https://images.pexels.com/photos/403571/pexels-photo-403571.jpeg?w=940&h=650&dpr=2&auto=compress&cs=tinysrgb');
	background-position: 100% 0;
	background-size: cover;
	position: fixed;
	top: 0;
	left: 0;
	transform: scaleX(-1); // Needed to mirror the original image, as I wanted the cactus displayed on the far right
	z-index: -1;
}

// HEADLINE DUPLICATE
	// Exists for JS purposes
.u-hidden {
	width: auto;
	opacity: 0;
	visibility: hidden;
	position: fixed;
}
            
          
!
            
              /* 
 * If you'd like to build this editable headline test, step by step, I wrote a post about it:
 * https://codepen.io/ilithya/post/fashion-headline
 */

var observeInputText = function () {
	
	var $inputHeadline = document.getElementById('is-headline'),
			$headlineVal 	 = document.getElementById('is-duplicate');

	function updateInputWidth() {
		// Get precise width of div elem containing the input placeholder/value duplicate
		var inputWidth = $headlineVal.clientWidth + 'px';

		// Add precise width of that div elem into the input field
		$inputHeadline.style.width = inputWidth;
	}

	function updatePlaceholderWidth() {	
		// Duplicate placeholder text into another container, a div elem
		$headlineVal.innerText = $inputHeadline.getAttribute('placeholder');

		updateInputWidth();
	}

	function listenInputText() {
		var $inputTxtVal = $inputHeadline.value;

		// Duplicate value/text entered on input field into another container, a div elem
		$headlineVal.innerText = $inputTxtVal;

		updateInputWidth();

		// Add default width to input field if no text has been entered
		if ($inputTxtVal === '') {
			updatePlaceholderWidth();
		}
	}

	updatePlaceholderWidth();
	$inputHeadline.addEventListener('keyup', listenInputText, false);
	
};

observeInputText();
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console