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

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

              
                <div class="tabs">
	<ul>
		<li><a href="#tabs-1">Example Tab</a></li>
		<li><a href="#tabs-2">Example Tab</a></li>
		<li><a href="#tabs-3">Example Tab</a></li>
	</ul>
	<div id="tabs-1">Lorem ipsum dolor sit amet, consectetur adipiscing elit. In auctor, nisi in blandit dapibus, est ante bibendum lacus, a molestie ligula elit nec mi. Aliquam imperdiet lacinia augue, vitae vestibulum lacus suscipit vitae. Nulla fringilla commodo mi, eget suscipit odio adipiscing sed. Aenean eu est et dolor venenatis tempor.</div>
	<div id="tabs-2">Donec ac sapien quam. Nunc dictum nunc ut enim pharetra, in semper quam imperdiet. Quisque ultricies neque eu metus convallis, sed pretium ante molestie. Proin pellentesque, ante non pellentesque auctor, metus est gravida tellus, a malesuada leo velit a neque. Nulla pulvinar rhoncus eleifend.</div>
	<div id="tabs-3">Vivamus accumsan arcu non lacus sagittis vulputate. Nullam odio magna, pellentesque eget sollicitudin non, rutrum sodales libero. Nullam sagittis, eros et tempor hendrerit, purus nunc viverra sapien, in molestie tortor elit nec enim. Sed placerat, risus a aliquet dapibus, nisl dui auctor erat, nec pellentesque libero justo ac risus. </div>
</div>
              
            
!

CSS

              
                
              
            
!

JS

              
                function updateUI(){
   
    if($(document).width() <= 480){
 
        // mobile view instructions
        tabsToAccordions();
 
    } else {
 
        // desktop view instructions
        accordionsToTabs();
    }
 
}
 
// changes tabs to accordions (jquery ui)
function tabsToAccordions(){
    $('.tabs').each(function(){
        var a = $('<div class="accordion">');
        var b = new Array();
        $(this).find('>ul>li').each(function(){
            b.push('<h3>'+$(this).html()+'</h3>');
        });
        var c = new Array();
        $(this).find('>div').each(function(){
            c.push('<div>'+$(this).html()+'</div>');
        });
        for(var i = 0; i < b.length; i++){
            a.append(b[i]).append(c[i]);
        }
        $(this).before(a);
        $(this).remove();
    })
    $('.accordion').accordion()
}
 
// changes accordions to tabs (jquery ui)
function accordionsToTabs(){
    $('.accordion').each(function(){
        var a = $('<div class="tabs">');
        var count = 0;
        var b = $('<ul>');
        $(this).find('>h3').each(function(){
            count++;
            b.append('<li><a href="#tabs-'+count+'">'+$(this).text()+'</a></li>');
        });
        var count = 0;
        var c = $('');
        $(this).find('>div').each(function(){
            count++;
            c=c.add('<div id="tabs-'+count+'">'+$(this).html()+'</div>');
        });
        a.append(b).append(c);
        $(this).before(a);
        $(this).remove();
    });
    $('.tabs').tabs();
}


// event handler for window resize
$(window).resize(function(e){
  updateUI();
});
updateUI();
              
            
!
999px

Console