Navtabs provide a tab-based navagation directly in your content, allowing users to click from tab to tab to see different panels of content. Navtabs are especially helpful for showing code samples for different programming languages. The only downside to using navtabs is that you must use HTML instead of Markdown.

Common uses

Navtabs are particularly useful for scenarios where you want to show a variety of options, such as code samples for Java, .NET, or PHP, on the same page.

While you could resort to single-source publishing to provide different outputs for each unique programming language or role, you could also use navtabs to allow users to select the content you want.

Navtabs are better for SEO since you avoid duplicate content and drive users to the same page.

The following is a demo of a navtab. Refresh your page to see the tab you selected remain active.

Profile

Praesent sit amet fermentum leo. Aliquam feugiat,

  1. nibh in u ltrices mattis
  2. felis ipsum venenatis metus, vel vehicula libero mauris a enim. Sed placerat est ac lectus vestibulum tempor.
    • Quisque ut condimentum massa.
    • ut condimentum massa.

Proin venenatis leo id urna cursus blandit. Vivamus sit amet hendrerit metus.

About

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam vel sollicitudin felis. Sed eu arcu sed ipsum semper luctus eu a tortor. Suspendisse id leo eu metus laoreet varius. Mauris consequat accumsan ex, a iaculis metus fermentum a. Praesent sit amet fermentum leo. Aliquam feugiat, nibh in u ltrices mattis, felis ipsum venenatis metus, vel vehicula libero mauris a enim. Sed placerat est ac lectus vestibulum tempor. Quisque ut condimentum massa. Proin venenatis leo id urna cursus blandit. Vivamus sit amet hendrerit metus.about

Match

Vel vehicula libero mauris a enim. Sed placerat est ac lectus vestibulum tempor. Quisque ut condimentum massa. Proin venenatis leo id urna cursus blandit. Vivamus sit amet hendrerit metus.

Code

Here’s the code for the above (with the filler text abbreviated):

<ul id="profileTabs" class="nav nav-tabs">
    <li class="active"><a href="#profile" data-toggle="tab">Profile</a></li>
    <li><a href="#about" data-toggle="tab">About</a></li>
    <li><a href="#match" data-toggle="tab">Match</a></li>
</ul>
  <div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="profile">
    <h2>Profile</h2>
<p>Praesent sit amet fermentum leo....</p>
</div>

<div role="tabpanel" class="tab-pane" id="about">
    <h2>About</h2>
    <p>Lorem ipsum ...</p></div>

<div role="tabpanel" class="tab-pane" id="match">
    <h2>Match</h2>
    <p>Vel vehicula ....</p>
</div>
</div>

Design constraints

Bootstrap automatically clears any floats after the navtab. Make sure you aren’t trying to float any element to the right of your navtabs, or there will be some awkward space in your layout.

Appearance in the mini-TOC

If you put a heading in the navtab content, that heading will appear in the mini-TOC as long as the heading tag has an ID. If you don’t want the headings for each navtab section to appear in the mini-TOC, omit the ID attribute from the heading tag. Without this ID attribute in the heading, the mini-TOC won’t insert the heading title into the mini-TOC.

Must use HTML

You must use HTML within the navtab content because each navtab section is surrounded with HTML, and you can’t use Markdown inside of HTML.

Match up ID tags

Each tab’s href attribute must match the id attribute of the tab content’s div section. So if your tab has href="#acme", then you add acme as the ID attribute in <div role="tabpanel" class="tab-pane" id="acme">.

Set an active tab

One of the tabs needs to be set as active, depending on what tab you want to be open by default (usually the first one).

<div role="tabpanel" class="tab-pane active" id="acme">

The navtabs are part of Bootstrap, but this theme sets a cookie to remember the last tab’s state. The js/customscripts.js file has a long chunk of JavaScript that sets the cookie. The JavaScript comes from this StackOverflow thread.

By setting a cookie, if the user refreshes the page, the active tab is the tab the user last selected (rather than defaulting to the default active tab).

Functionality to implement

One piece of functionality I’d like to implement is the ability to set site-wide nav tab options. For example, if the user always chooses PHP instead of Java in the code samples, it would be great to set this option site-wide by default. However, this functionality isn’t yet coded.

orzh-introduction

X-WAF-README

nginx-lua-module-zh-wiki

orange_about

pra_flame_how

orzh-introduction

X-WAF-README

nginx-lua-module-zh-wiki

orange_about

titlepage

tocpage

p1_landing_page

p1_sample1

p1_sample2

p1_sample3

p1_sample4

p1_sample5

p1_sample6

p1_sample7

titlepage

tocpage

p2_landing_page

p2_sample1

p2_sample2

p2_sample3

p2_sample4

p2_sample5

p2_sample6

p2_sample7

p2_sample8

p2_sample9

p2_sample10

p2_sample11

p2_sample12

p2_sample13

p2_sample14

titlepage

tocpage

p1_landing_page

p1_sample1

p1_sample2

p1_sample3

p1_sample4

p1_sample5

p1_sample6

p1_sample7

titlepage

tocpage

X-WAF-README

xwaf_installation

xwaf_depoly

xwaf_README

xwaf_advanced_readme

xwaf_getting_started

xwaf_faqs_readme

xwaf_roadmap

titlepage

tocpage

nginx-lua-module-zh-wiki

titlepage

tocpage

orange_api_server

orange_build_plugin

orange_dashboard_usage

orange_README

orange_basic_auth

orange_basic_info

orange_divide

orange_key_auth

orange_monitor

orange_rate_limiting

orange_redirect

orange_rewrite

orange_stat

orange_waf

orange_condition

orange_expression

orange_extraction

orange_extractor

orange_handle

orange_judge

orange_rule

orange_about

orange_contributing

orange_issues

orange_usages

titlepage

tocpage

add_new_lua_api

cosocket

get_req_body

get_url_param

helloworld

how_request_http

inline_var

install

install_on_centos

install_on_ubuntu

install_on_windows

install_osx

log_response

outtest

response

safe_sql

share_var

simple_api

sub_request

work_with_location

array_size

break

brief

build_env

call_user_func_array

capture

class

control_structrues

dot_diff

dummy_var

FFI

file

for

function_before_use

function_define

function_descrip

function_parameter

function_result

if_else

local

main

math_library

metatable

module_is_evil

module

not_nill

not_use_lib

not_use_module

object_oriented

operator

re

repeat

string_library

table_library

time_date_function

what_jit

while

pra_flame_how

pra_flame_install

pra_flame_what

pra_flame_when

pra_ngx_lua_allow_deny

pra_ngx_lua_block_io

pra_ngx_lua_cache

pra_ngx_lua_capture

pra_ngx_lua_continue_after_eof

pra_ngx_lua_debug

pra_ngx_lua_ffi

pra_ngx_lua_hot_load

pra_ngx_lua_how_one_instance_time

pra_ngx_lua_how_use_third_lib

pra_ngx_lua_keepalive

pra_ngx_lua_log

pra_ngx_lua_lua-limit

pra_ngx_lua_lua_opt

pra_ngx_lua_lua-variable-scope

pra_ngx_lua_on_abort

pra_ngx_lua_phase

pra_ngx_lua_resolve_the_domain_name

pra_ngx_lua_shared_get_keys

pra_ngx_lua_sleep

pra_ngx_lua_timer

pra_ngx_lua_use_case

pra_ngx_lua_whats_cosocket

pra_redis_auth_connect

pra_redis_dynamic_redis_module_method

pra_redis_out_package

pra_redis_pipeline

pra_redis_pub_sub_package

pra_redis_script

pra_redis_select-keeplive

pra_postgres_health_check

pra_postgres_how_to_use

pra_postgres_not_support_transaction

pra_postgres_sql_inject

pra_postgres_timeout

pra_nginx_balancer

pra_nginx_co-work_of_location

pra_nginx_if_is_evil

pra_nginx_match_uri

pra_nginx_nginx_brief

pra_nginx_nginx_local_pcre

pra_nginx_nginx_log

pra_nginx_nginx

pra_nginx_pitfalls_and_common_mistakes

pra_nginx_reverse_proxy

pra_nginx_static_file

titlepage

tocpage

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_scan_port

candylab_common_sites_log_system

candylab_graylog_clickhouse

candylab_clickhouse_basic

candylab_logs_and_gateway

candylab_sec_system_arch

candylab_logs_dsl_waf

candylab_opensock_list

candylab_opensock_practice

candylab_opensock_email

candylab_base_on_openresty_waf

candylab_dsl_waf

candylab_honeypot_system

candylab_monitor_redis

candylab_threat_replay

candylab_pcap_monitor

candylab_monitor_website

candylab_openrestyplus_waf

candylab_windows_bigdata

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

candylab_clickhouse_basic

mydoc_hyperlinks.html#automatedlinks

mydoc_hyperlinks.html#bookmarklinks

mydoc_pages.html#someIdTag

news

nginx-lua-module-zh-wiki

nginx-development-guide-zh

orange_about

X-WAF-README

pra_flame_how

Tags: formatting