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

              
                
<header class='container header'>
<div class='inner-w'>
	
	<h1>Fixed header on "no-touch" only devices.</h1>

</div>
</header>



<section class='container content'>
<div class='inner-w'>

	<p>So, I love fixed headers. I thought the header I did for <a href="http://timenoplace.com" target="_blank">Time No Place</a> was really cool, but mobile browsers, and the new desktop style tablets with touch, just cant handle it. I was testing in a big-box store recently and all of the fixed headers jump around like fish out of water when you scroll. This cannot be allowed.</p> <p>On a new project for a book series with authors <a href="http://camandbenny.com">Cam&nbsp;Baity and Benny&nbsp;Zelkowicz</a>, I had envisioned a fixed seal in the upper left corner, so what to do?</p>   
    <P>While I can't test for "things that don't work good," I can test if something has "touch" capabilities with modernizr. This is cool. So if it finds there is "no-touch" than I can make some assumptions and provide an alternate rule.</p>
    <button class="button">toggle "no-touch" class</button>

</div>
</section>
              
            
!

CSS

              
                
.header
	theme(highlight)
	opacity: .9
	height: 80px

.content
	// just to get it scrolling
	min-height: 800em
	padding-top: 40px

.no-touch
	.header
		fixed()
		top: 0
		left: 0
		z-index: 10
		box-shadow: 0 0 10px 0 rgba(0,0,0,.5)
		theme(color)
	.content
		padding-top: 120px

p //
	margin-bottom: $pad

.button
	margin-top: $pad
              
            
!

JS

              
                
$('button').on('click', function() {
  $('html').toggleClass('no-touch');
});

              
            
!
999px

Console