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


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


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.


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.


                <nav id="main_nav"></nav>

<h3>Menu modeled in Kontent</h3>
<p>No part of the navigation is hardcoded, it's all dynamically generated based on dedicated content items retrieved from your Kontent project. </p>
<p>Uncomment the CSS to see a proper navigation menu.</p>



* {
  margin: 0;
  padding: 0;

body {
  font: sans-serif;
  font-size: 12px;
  background: #eee;
  margin: 1em;
  padding: 1.5em;

h1 {
  display: block;
  font-size: 2em;
  font-weight: 400;


a {
  color: #06c;

nav {
  min-height: 35px;

nav ul {
  background: #ccc;
  float: left;
  -webkit-transition: .5s;
  transition: .5s;

nav li {
  float: left;
  position: relative;
  width: 150px;
  list-style: none;
  -webkit-transition: .5s;
  transition: .5s;
  border-bottom: 1px solid #999;

nav > ul > li > a, h1 {
  text-transform: uppercase;

nav a {
  display: block;
  text-decoration: none;
  padding: 5px 15px;
  color: #000;

nav ul ul {
  position: absolute;
  left: 0;
  top: 100%;
  visibility: hidden;
  opacity: 0;

nav ul ul ul {
  left: 100%;
  top: 0;

nav li:hover, nav li:hover li {
  background: #ddd;

nav li li:hover, nav li li:hover li {
  background: #bbb;

nav li li li:hover {
  background: #999;

nav li:hover > ul {
  visibility: visible;
  opacity: 1;



                // Use jQuery to request the Main menu content item using Kentico Cloud Delivery API.
  type: "GET",
  url: "",
  dataType: "json",
  success: processData,
  error: function() {

// Process the retrieved data using the itemsToList function and display it on the page.
function processData(data) {
  var rootMenuItems = data.item.elements.subitems.value;
  var allLinkedContent = data.modular_content;
  var menuHtml = itemsToList(rootMenuItems, allLinkedContent, 0);

// Limit recursion depth in case of cyclic references between content items. 
// (Otherwise your menu would be infinitely large and your site would crash.)
const DEPTH_LIMIT = 5;

// Generate menu HTML by recursively transforming content items to list elements.
function itemsToList(itemCodenames, linkedContent, currentDepth) {
    if(currentDepth >= DEPTH_LIMIT) {
      return "";
    var result = "<ul>";
    for(let itemCodename of itemCodenames){
      let title = linkedContent[itemCodename].elements.title.value;
      let url = linkedContent[itemCodename].elements.url.value;
      if (linkedContent[itemCodename].elements.subitems) {
        let subitems = linkedContent[itemCodename].elements.subitems.value;
        // console.log(title, url);
        result += "<li><a href='#/"+ url +"' title='/"+ url +"'>" + title + "</a>"
               + itemsToList(subitems, linkedContent, currentDepth+1) +"</li>";  
      else {
        result += "<li><a href='#/"+ url +"' title='/"+ url +"'>" + title + "</a></li>";  
    result += "</ul>";
    return result;