<nav id="demo4">
<!-- "first level" -->
<div class="UXN__subnav UXN__subnav--top-level">
<!-- the only item in the "first level" -->
<div class="UXN__item UXN__item--top-level">
<span>Categories</span>
<!-- second level - list with categories -->
<ul class="UXN__subnav UXN__subnav--categories">
<!-- categories -->
<li class="UXN__item UXN__item--category">
<a href="#">Category 1</a>
<!-- third level - category -->
<div class="UXN__subnav UXN__subnav--category">
<img src="http://lorempixel.com/400/600/food/5/" alt="">
<h2>Category 1</h2>
<a href="#">Item in category 1 <span>description of the item</span></a>
...
<!-- links in the category -->
</div>
<!-- third level -->
</li>
...
<!-- categories -->
</ul>
<!-- second level -->
</div>
<!-- item in the "first level" -->
</div>
<!-- "first level" -->
</nav>
CSS
#demo4 {
font-size: 18px;
font-family: open-sans;
margin: 50px 35px;
width: 144px;
height: 44px;
color: #23556a;
}
#demo4 a {
text-decoration: none;
color: #23556a;
}
#demo4 .UXN__subnav {
list-style: none;
background-color: #f4f4f4;
box-shadow: 0 0 10px 0 rgba(10, 51, 68, 0.35);
}
#demo4 .UXN__subnav--top-level {
float: left;
border: 1px solid #6b9bae;
border-radius: 6px;
}
#demo4 .UXN__subnav--categories {
position:absolute;
top: 125%;
left: -1px;
transform: translateY(-10px);
padding: 10px 0px;
width: 190px;
border-radius: 6px;
background-color: #fff;
/* hide submenus */
opacity: 0;
visibility: hidden;
overflow: hidden;
transition:
width 0.3s ease-in 0s,
opacity 0.15s ease-in 0s,
transform 0.15s ease-in 0s,
visibility 0s 0.15s;
/* Visibility is delayed to the end of the transition.
* Using "visibility" in transitions is strongly recommended. */
}
#demo4 .UXN__subnav--categories.UXN__subnav--has-opened {
width: 640px;
}
/* show categories list */
#demo4 .UXN__item--opened > .UXN__subnav--categories,
#demo4 .UXN__item--opened.UXN__item--top-level:after {
transform: translateY(0px);
opacity: 1;
visibility: visible;
}
#demo4 .UXN__item--opened > .UXN__subnav--categories,
#demo4 .UXN__item--opened.UXN__item--top-level:after {
transition:
width 0.3s ease-out,
opacity 0.15s ease-out,
transform 0.15s ease-out; /* visibility is removed from the transition; strongly recommended pattern */
}
#demo4 .UXN__subnav--category {
position:absolute;
top: 0px;
left: 190px;
padding: 15px 25px;
width: 450px;
height: 100%;
box-sizing: border-box;
box-shadow: none;
border-left: 1px solid #b8c9d2;
opacity: 0;
visibility: hidden;
overflow: hidden;
transition:
opacity 0.3s ease-in 0s,
visibility 0s 0.3s;
/* Here the "visibility pattern" is not necessary, because parent items do not have "overflow: hidden".
* In that case these submenus should have a "UXN-no-fading" class. */
}
#demo4 .UXN__subnav--category > * {
position: relative;
z-index: 2;
}
#demo4 .UXN__subnav--category h2 {
font-size: 20px;
clear: both;
margin-bottom: 10px;
color: #23556a;
}
#demo4 .UXN__subnav--category h2 ~ h2 {
padding-top: 5px;
}
#demo4 .UXN__subnav--category a {
font-size: 14px;
float: left;
clear: both;
margin-bottom: 10px;
color: #1b4253;
transition:
color 0.05s ease-in,
font 0.05s ease-in;
}
#demo4 .UXN__subnav--category a:hover {
font-weight: bold;
color: #23556a;
transition:
color 0.05s ease-out,
font 0.05s ease-out;
}
#demo4 .UXN__subnav--category a span {
font-size: 12px;
font-weight: normal;
color: #59727d;
display: block;
}
#demo4 .UXN__subnav--category img {
position:absolute;
top: 0px;
right: 0px;
z-index: 0;
}
#demo4 .UXN__subnav--category:after {
content: "";
position: absolute;
top: 0px;
left: 0px;
width: 100%;
height: 100%;
background: #fff;
background:
linear-gradient(125deg, #fff 5%, transparent 55%),
linear-gradient( 75deg, #fff 5%, transparent 55%),
linear-gradient( 90deg, #fff 10%, transparent 70%);
}
/* show category */
#demo4 .UXN__item--opened > .UXN__subnav--category {
z-index: 2;
opacity: 1;
visibility: visible;
transition: opacity 0.15s ease-out 0s;
}
/* opening element - "Categories" */
#demo4 .UXN__item--top-level {
position: relative;
border-radius: 6px;
overflow: hidden; /* submenus would otherwise be rendered on the page */
cursor: default;
}
/* arrow */
#demo4 .UXN__item--top-level:after {
content: "";
position:absolute;
bottom: -25%;
left: 106px;
transform: translateY(-10px);
border: 15px solid;
border-color: transparent transparent #fff transparent;
opacity: 0;
visibility: hidden;
transition:
opacity 0.15s ease-in 0s,
transform 0.15s ease-in 0s,
visibility 0s 0.15s;
}
#demo4 .UXN__item--top-level > span {
padding: 9px 15px 9px 18px;
display: block;
}
#demo4 .UXN__item--top-level > span:after {
content: "\2193";
font-size: 20px;
line-height: 0;
margin-left: 9px;
position: relative;
top: 0px;
}
#demo4 .UXN__item,
#demo4 .UXN__item > a {
transition:
background 0.15s ease-in,
color 0.15s ease-in;
}
#demo4 .UXN__item:hover,
#demo4 .UXN__item:hover > a,
#demo4 .UXN__item.UXN__item--highlighted,
#demo4 .UXN__item.UXN__item--highlighted > a {
transition:
background 0.15s ease-out,
color 0.15s ease-out;
}
#demo4 .UXN__item.UXN__item--opened,
#demo4 .UXN__item.UXN__item--has-fading-out {
overflow: visible; /* opened and fading (!) submenu would not be visible */
}
#demo4 .UXN__item--top-level:hover,
#demo4 .UXN__item:hover > a,
#demo4 .UXN__subnav--top-level:hover {
background-color: #0b6185;
color: #fff;
}
/* Visual styles of an opened item are set by .UXN__item--highlighted not .UXN__item--opened,
* but because the position adjustment is not enabled, it actually does not matter. */
#demo4 .UXN__item--top-level.UXN__item--highlighted,
#demo4 .UXN__item.UXN__item--highlighted > a,
#demo4 .UXN__subnav--top-level.UXN__subnav--has-opened {
background-color: #1b4253;
color: #fff;
}
#demo4 .UXN__item--category {
width: 190px;
}
#demo4 .UXN__item--category > a {
font-size: 16px;
position: relative;
width: 140px;
padding: 6px 25px;
display: block;
}
#demo4 .UXN__item--category.UXN__item--has-subnav > a:after {
content: "\2192";
line-height: 0;
position: absolute;
right: 15px;
top: 16px;
color: #b8c9d2;
transition:
right 0.15s ease-in,
color 0.15s ease-in;
}
#demo4 .UXN__item.UXN__item--highlighted > a:after,
#demo4 .UXN__item:hover > a:after {
color: #fff;
transition:
right 0.15s ease-out,
color 0.15s ease-out;
}
#demo4 .UXN__item.UXN__item--highlighted > a:after {
right: 0px;
}
JavaScript
new UXN({
nav: "#demo4",
item: ".UXN__item",
subnav: ".UXN__subnav",
fading: UXN.FADING_TYPE.TRANSITION,
// category is opened without having to stop the mouse even if the mouse is moving vertically
ignoreLayoutOnSliding: true,
minZoneExt: 0,
maxZoneExt: 15,
mouseTolerance: 0.25
});
Demo #5: Animations with jQuery
HTML
<nav id="demo5">
<ul class="UXN-horizontal">
<!-- UXN-horizontal: not necessary if "allowSlidingOnFirstLevel" is set to false or "ignoreLayoutOnSliding" to true -->
<!-- first level items -->
<li><a href="#">Item</a>
<ul>
<!-- second level items -->
<li><a href="#">Item</a>
<ul>
<!-- third level items -->
<li><a href="#">Item</a>
...
</li>
...
<!-- third level items -->
</ul>
</li>
...
<!-- second level items -->
</ul>
</li>
...
<!-- first level items -->
</ul>
</nav>
CSS
#demo5 {
font-size: 18px;
font-family: open-sans;
margin: 50px 35px;
}
#demo5 ul {
list-style: none;
background-color: #f4f4f4;
box-shadow: 0 0 10px 0 rgba(10, 51, 68, 0.35);
}
#demo5 .UXN-horizontal {
height: 40px;
border: 1px solid #6b9bae;
}
#demo5 ul ul {
position: absolute;
top: 100%;
width: 100%;
display: none; /* hide submenus */
}
/* Notice that although a submenu will be displayed with jQuery,
* the submenu must be openable with a .UXN__item--opened class,
* so that the position adjustment process works properly. */
#demo5 .UXN__item--opened > ul {
display: block; /* show opened submenu */
}
#demo5 .UXN-horizontal > li > ul {
left: -1px;
width: calc(100% + 1px);
}
#demo5 .UXN-horizontal > li ~ li > ul {
left: 1px;
width: calc(100% - 1px);
}
#demo5 .UXN-horizontal > li + li + li + li + li > ul {
width: 100%;
}
/* third level + */
#demo5 ul ul ul {
left: 95%;
top: 25%; /* default direction: down-right */
min-width: 175px;
}
/* opposite of the default direction */
#demo5 .UXN__subnav--left {
left: auto;
right: 95%;
}
/* opposite of the default direction */
#demo5 .UXN__subnav--top {
top: auto;
bottom: 25%;
}
#demo5 li,
#demo5 li:after,
#demo5 a {
transition:
color 0.15s ease-in,
background 0.15s ease-in;
}
#demo5 li:hover,
#demo5 li:hover:after,
#demo5 li:hover > a,
#demo5 .UXN__item--highlighted,
#demo5 .UXN__item--highlighted:after,
#demo5 .UXN__item--highlighted > a {
transition:
color 0.15s ease-out,
background 0.15s ease-out;
}
#demo5 li {
text-align: left;
position: relative;
float: left;
color: #23556a;
width: 20%;
}
#demo5 li li {
float: none;
width: 100%;
}
#demo5 li:hover {
background-color: #0b6185;
color: #fff;
}
/* Visual styles of an opened item are set by .UXN__item--highlighted not .UXN__item--opened,
* otherwise the styles would be visible during the position adjustment process. */
#demo5 li.UXN__item--highlighted {
z-index: 2;
background-color: #1b4253;
color: #fff;
}
#demo5 ul ul .UXN__item--has-left {
text-align: right;
}
#demo5 a {
text-decoration: none;
line-height: 40px;
padding: 0 40px 0 20px;
color: #1b4253;
display: block;
}
#demo5 .UXN__item--highlighted > a,
#demo5 a:hover {
color: #fff;
}
#demo5 .UXN-horizontal > li ~ li > a {
border-left: 1px solid #abc2ce;
}
#demo5 ul ul .UXN__item--has-left > a {
padding: 0 20px 0 40px;
}
#demo5 .UXN__item--has-subnav:after {
line-height: 40px;
position: absolute;
right: 20px;
top: 0;
color: #20546a;
}
#demo5 .UXN-horizontal > .UXN__item--has-subnav:after {
content: "\2193";
}
#demo5 .UXN__item--has-subnav:after {
content: "\2192";
}
#demo5 ul ul .UXN__item--has-left:after {
content: "\2190";
left: 20px;
right: auto;
}
#demo5 .UXN__item--has-subnav:hover:after,
#demo5 .UXN__item--opened:after {
color: #fff;
}
JavaScript
new UXN({
nav: "#demo5",
setPositions: true,
firstLevelPositionBase: $("#demo5").closest(".examples__tab"),
fading: UXN.FADING_TYPE.JS,
onOpen: function ($subnav, $opener, $item) {
$subnav.stop().slideDown(150);
},
onClose: function ($subnav, $opener, $item, done) {
$subnav.stop().slideUp(150, function () {
/* At the end of the animation the "done" function must be called
* and the "display" property must be removed from the style
* attribute to be able to open this submenu with a class
* during the position adjustment process. */
$subnav.css("display", "");
done();
});
}
});
Demo #6: Another type of navigation
HTML
<nav id="demo6">
<!-- first level - list of categories -->
<ul class="UXN__subnav UXN__subnav--categories UXN-sliding--horizontal">
<!-- UXN-sliding--horizontal - if the mouse is moving horizontally, the items will be opened without having to stop the mouse -->
<!-- categories -->
<li class="UXN__item UXN__item--category">
<a href="#">Category</a>
<!-- second level - list of subcategories -->
<ul class="UXN__subnav UXN__subnav--subcategories UXN-sliding--vertical UXN-sliding--horizontal UXN-exclude--inside">
<!-- UXN-sliding--horizontal + UXN-sliding--vertical - the items will be opened without having to stop the mouse regardless of the direction of the mouse movement -->
<!-- subcategories -->
<li class="UXN__item UXN__item--subcategory">
<a href="#">Subcategory</a>
<!-- third level - articles -->
<div class="UXN__subnav UXN__subnav--subcategory UXN-no-fading UXN-exclude--inside">
<!-- UXN-exclude--inside - exclude this submenu from mouse tracking (slight optimization; not necessary) -->
<!-- UXN-no-fading - the submenu doesn't use transitions (required) -->
<article>
<a href="#">
<img src="http://lorempixel.com/400/250/city/5/" alt="">
<h2>Title of the Article</h2>
</a>
</article>
...
<!-- articles -->
</div>
<!-- third level -->
</li>
...
<!-- subcategories -->
</ul>
<!-- second level -->
</li>
...
<!-- categories -->
</ul>
<!-- first level -->
</nav>
new UXN({
nav: "#demo6",
item: ".UXN__item",
subnav: ".UXN__subnav",
delayHide: true, // hide submenu just before the other is opened
closeOnlyInLevel: true, // "save" last opened subcategory
allowSlidingOnFirstLevel: true,
fading: UXN.FADING_TYPE.TRANSITION,
// On touch devices we need to block the possibility of closing all subcategories.
onClose: function ($subnav, $opener, $item) {
if ($item.hasClass("UXN__item--subcategory") && this.$currentItem[0] === $item[0]) {
return false;
}
},
// If there is no opened subcategory, the first is opened.
onOpen: function ($subnav, $opener, $item) {
if ($item.hasClass("UXN__item--category") && !this.hasSubnavOpenedSubnav($subnav)) {
this.open(this.getSubnav($subnav), true /* we don't need to open parent submenus */);
}
},
onSubnavChange: function ($current) {
if ($current[0] === this.$firstLevel[0]) {
this.opt.mouseTolerance = 0;
} else {
this.opt.mouseTolerance = 0.25;
}
},
minZoneExt: 0,
maxZoneExt: 15,
mouseTolerance: 0.25
});
#demo7 {
font-size: 18px;
font-family: open-sans, sans-serif;
margin: 100px 25px;
}
#demo7 ul {
text-align: center;
list-style: none;
}
#demo7 ul .UXN__subnav {
z-index: 2;
position:absolute; /* default direction: top */
top: -90px;
left: -94px;
transform: scale(0);
transform-origin: 50% 118px;
background-color: #1b4253;
border-radius: 6px;
box-shadow: 0 0 10px 0 rgba(10, 51, 68, 0.35);
/* hide bubbles */
visibility: hidden;
opacity: 0;
transition:
opacity 0.25s ease-in 0s,
transform 0.25s ease-in 0s,
visibility 0s 0.25s;
/* Visibility is delayed to the end of the transition.
* Using "visibility" in transitions is strongly recommended. */
}
/* triangle */
#demo7 ul .UXN__subnav:after {
content: "";
position: absolute;
bottom: -38px;
left: 99px;
width: 0;
height: 0;
border: 19px solid;
border-color: #1b4253 transparent transparent transparent;
}
#demo7 ul .UXN__subnav--left {
left: -179px;
transform-origin: 203px 118px;
}
#demo7 ul .UXN__subnav--left.UXN__subnav--bottom {
left: -179px;
transform-origin: 203px -44px;
}
/* triangle */
#demo7 ul .UXN__subnav--left:after {
left: 184px;
}
#demo7 ul .UXN__subnav--right {
left: auto;
right: -179px;
transform-origin: 37px 118px;
}
#demo7 ul .UXN__subnav--right.UXN__subnav--bottom {
left: auto;
right: -179px;
transform-origin: 37px -44px;
}
/* triangle */
#demo7 ul .UXN__subnav--right:after {
left: auto;
right: 184px;
}
#demo7 ul .UXN__subnav--bottom {
top: 75px;
transform-origin: 50% -44px;
}
/* triangle */
#demo7 ul .UXN__subnav--bottom:after {
top: -38px;
border-color: transparent transparent #1b4253 transparent;
}
#demo7 ul .UXN__subnav span {
font-size: 18px;
line-height: 32px;
text-align: center;
padding: 15px 10px;
width: 220px;
height: 32px;
display: block;
}
#demo7 ul .UXN__subnav a {
font-size: 13px;
font-weight: 400;
text-decoration: none;
white-space: nowrap;
color: #fff;
transition: font 0.05s ease-in;
}
#demo7 ul .UXN__subnav a:hover {
font-weight: 700;
transition: font 0.05s ease-out;
}
/* show opened bubble */
#demo7 .UXN__item--opened > .UXN__subnav {
transform: scale(1);
opacity: 1;
visibility: visible;
transition:
transform 0.25s ease-out 0s,
opacity 0.25s ease-out 0s;
/* visibility is removed from the transition; strongly recommended pattern */
}
#demo7 .UXN__item {
font-family: MeteoconsRegular;
font-size: 32px;
line-height: 50px;
text-align: left;
text-indent: 8px;
position: relative;
float: left;
width: 48px;
height: 48px;
color: #1b4253;
background-color: #f4f4f4;
border: 2px solid #23556a;
border-radius: 50%;
box-shadow: 0 0 10px 0 rgba(10, 51, 68, 0.35);
overflow: hidden; /* bubbles would otherwise be rendered on the page */
cursor: default;
transition:
background 0.15s ease-in,
color 0.15s ease-in,
border 0.15s ease-in;
}
#demo7 .UXN__item * {
font-family: open-sans, sans-serif;
}
#demo7 .UXN__item + .UXN__item {
margin-left: 12.2%;
margin-left: calc((100% / 5) - 62.5px);
}
#demo7 .UXN__item + .UXN__item + .UXN__item + .UXN__item + .UXN__item + .UXN__item {
line-height: 53px;
}
#demo7 .UXN__item--opened,
#demo7 .UXN__item--has-fading-out {
overflow: visible; /* opened and fading (!) bubble would not be visible */
}
#demo7 .UXN__item:hover,
#demo7 .UXN__item--highlighted:hover,
#demo7 .UXN__item--opened {
color: #fff;
transition-timing-function: ease-out;
}
#demo7 .UXN__item:hover {
border-color: #0b6185;
background-color: #0b6185;
}
/* Visual styles of an opened item are set by .UXN__item--highlighted not .UXN__item--opened,
* otherwise the styles would be visible during the position adjustment process. */
#demo7 .UXN__item--highlighted:hover,
#demo7 .UXN__item--highlighted {
border-color: #1b4253;
background-color: #1b4253;
}
JavaScript
new UXN({
nav: "#demo7",
item: ".UXN__item",
subnav: ".UXN__subnav",
setPositions: true,
firstLevelPositionBase: $("#window"), // simulated window
firstLevelPositionsFromCenter: false,
// Position of a bubble is changed, if it exceeds the edges of the window.
// If the "firstLevelPositionBase" is set, the default value is "true".
fading: UXN.FADING_TYPE.TRANSITION
});