I am having problems trying to center the navigation bar on my web page. I tried creating a wrapper div to center it, but it doesn't seem to work. The only thing that works in that div are changing the left margin. Here is the HTML:
body {
background: #bf5c71 url('body-bg.jpg');
}
.clearfix:after {
display: inline-block;
clear: both;
align-content: center;
}
/*----- Menu Outline -----*/
.menu-wrap {
box-shadow: inset 0px 0 0 rgba(255, 255, 255, 0.00);
-webkit-box-shadow: inset 0px 0 0 rgba(255, 255, 255, 0.00);
display: inline-block;
margin: 0px auto;
}
.menu {
display: inline-block;
margin: auto;
}
.menu li {
margin-top: 0px;
margin-right: 0px;
margin-left: 0px;
margin-bottom: 0px;
list-style: none;
font-family: 'Century Gothic';
}
.menu a {
transition: all linear 0.15s;
color: #FF283B;
}
.menu li:hover > a,
.menu .current-item > a {
color: #F5F5F5;
}
.menu .arrow {
font-size: 11px;
line-height: 0%;
}
/*----- Top Level -----*/
.menu > ul > li {
float: left;
display: inline-block;
position: relative;
font-size: 18px;
}
.menu > ul > li > a {
padding-top: 2px;
padding-right: 2px;
padding-left: 2px;
padding-bottom: 2px;
display: inline-block;
text-shadow: 0px 0px 0px rgba(0, 0, 0, 0.00);
}
.menu > ul > li:hover > a,
.menu > ul > .current-item > a {
background: F5F5F5;
}
/*----- Bottom Level -----*/
.menu li:hover .sub-menu {
z-index: 1;
opacity: 1;
}
.sub-menu {
width: 100%;
padding: 3px 0px;
position: absolute;
top: 100%;
left: 0px;
z-index: -1;
opacity: 0;
transition: opacity linear 0.15s;
box-shadow: 0px 0px 0px rgba(0, 0, 0, 0.0);
background: 0;
}
.sub-menu li {
display: inline-block;
font-size: 16px;
}
.sub-menu li a {
padding-top: 10px;
padding-right: 20px;
padding-left: 20px;
padding-bottom: 5px;
display: inline-block;
}
.sub-menu li a:hover,
.sub-menu .current-item a {
background: #FF283B;
}
img {
border: thin solid #FF283B;
margin-left: 5%;
}
h3 {
margin-top: 3%;
font-size: 24px;
}
.wrapper {
display: inline-block;
margin: 0px auto;
}
<div class="wrapper">
<div class="menu-wrap">
<nav class="menu">
<ul class="clearfix">
<li>
<div align="center">Home</a>
</div>
</li>
<li>
<div align="center">Projects <span class="arrow">▼</span>
<ul class="sub-menu">
<li>Image Adaptation
</li>
<li>Sonic Memory
</li>
<li>Documentary Video
</li>
</ul>
</div>
</li>
<li>
<div align="center">Resume
</div>
</li>
<li>
<div align="center">About
</div>
</li>
<li>
<div align="center">Contact
</div>
</li>
</ul>
</nav>
</div>
</div>
The only thing I can seem to do is just shift the bar left using margin-left.
Website: tylerbr.com
This is enough:
.content {
text-align: center;
}
You need to give your menu a width and change the display to "block"
Here is the style you need to change
.menu-wrap {
box-shadow: 0 0 0 rgba(255, 255, 255, 0) inset;
display: block;
margin: auto;
width: 880px;
}
Its a good idea to give a 100% width to the navbar. And the text-align center on the menu should do the trick.
.menu-wrap {
box-shadow: inset 0px 0 0 rgba(255,255,255,0.00);
-webkit-box-shadow: inset 0px 0 0 rgba(255,255,255,0.00);
display: inline-block;
margin: 0px auto;
width: 100%;
}
.menu {
width: 100%;
display: inline-block;
text-align: center;
}
What you are looking for is they style margin: 0 auto; take a look at this sample code and you will get it.
<style>
.wrapper{
width:100%;
height: 30px;
background: black;
}
.centered_div{
width: 200px;
background: red;
margin:0 auto;
}
</style>
<div class="wrapper">
<div class="centered_div">
test
</div>
</div>
Related
i've a small problem with my slide menu. The slide is fadin in from down to up. This also is working fine.
But now I want to set the position a bit more to the left side, so that i get a line with the main menu.
Maybe someone can help me. This is my sample...
This is my code... [Menu][1] https://jsfiddle.net/Tabes/eb52suo1/15/
Here is your solution
.flex-box {
width: 100%;
min-height: 0;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
flex-wrap: wrap;
flex-direction: row;
justify-content: space-between;
align-items: flex-start;
align-content: flex-start;
}
.navigation {
background-image: linear-gradient(#444, #111);
background-color: #111;
width: 100%;
}
/* ******************************************************************************************* */
/* ***** Main Navigation - Main Level ******************************************************* */
/* ******************************************************************************************* */
.nav_main {
background: transparent;
list-style: none;
}
.nav_main ul:before,
.nav_main ul:after {
content: "";
display: table;
}
.nav_main ul {
list-style: none outside none;
position: relative;
flex-wrap: nowrap;
justify-content: center;
align-items: center;
align-content: center;
margin: 0px;
padding: 0px;
min-width: auto;
min-height: auto;
zoom: 1;
}
.nav_main ul li:before,
.nav_main ul li:after {
content: "";
display: inline;
}
.nav_main ul li.icon:before,
.nav_main ul li.icon:after {
display: inline-block;
margin: 2px 15px 0px 0px;
width: 15px;
height: 15px;
}
.nav_main ul li.icon:before {
background: url("../pic/icons/glyphicons-387-log-in.png") no-repeat top right;
background-size: 15px;
float: left;
margin: 2px 15px 0px 0px;
}
.nav_main ul li.icon:after {
background: url("../pic/icons/glyphicons-415-disk-save.png") no-repeat top left;
background-size: 15px;
float: right;
margin: 2px 0px 0px 15px;
}
.nav_main ul li>img.before,
.nav_main ul li>img.after {
display: inline-block;
margin: 2px 15px 0px 0px;
width: 15px;
height: auto;
}
.nav_main ul li>img.before {
float: left;
margin: 2px 15px 0px 0px;
}
.nav_main ul li>img.after {
float: right;
margin: 2px 0px 0px 15px;
}
.nav_main ul li:last-child {
border-right: none;
box-shadow: none;
}
.nav_main ul li:hover {
background: #444;
display: inline-block;
margin: 0px;
padding: 10px 35px;
min-width: auto;
min-height: auto;
}
.nav_main ul li {
border-right: 1px solid #222;
box-shadow: 1px 0 0 #444;
cursor: pointer;
text-align: center;
display: inline-block;
flex: 0 0 auto;
position: relative;
margin: 0px;
padding: 10px 35px;
min-width: auto;
min-height: auto;
}
.nav_main ul li>a:hover {
color: #fafafa;
}
.nav_main ul li>a {
font: bold 12px Arial, Helvetica;
text-transform: uppercase;
text-decoration: none;
text-shadow: 0 1px 0 #000;
color: #999;
}
.nav_main ul li:hover>ul {
visibility: visible;
opacity: 1;
margin: 0;
}
/* ******************************************************************************************* */
/* ***** Main Navigation - Level #1 ******************************************************** */
/* ******************************************************************************************* */
.nav_main ul ul {
list-style: none outside none;
position: absolute;
background: #444;
box-shadow: 0 -1px 0 rgba(255, 255, 255, 0.3);
border-radius: 3px;
flex-direction: column;
align-items: flex-start;
visibility: hidden;
opacity: 0;
top: 40px;
left: 0;
z-index: 5;
transition: all 0.2s ease-in-out;
margin: 10px 0px 0px 0px;
padding: 0px;
min-width: 185px;
min-height: 35px;
width: auto;
}
.nav_main ul ul li:before,
.nav_main ul ul li:after {
content: "";
display: inline;
}
.nav_main ul ul li.icon:before,
.nav_main ul ul li.icon:after {
display: inline-block;
margin: 4px 35px 0px 0px;
width: 15px;
height: 15px;
}
.nav_main ul ul li.icon:before {
background: url("../pic/icons/glyphicons-387-log-in.png") no-repeat top right;
background-size: 15px;
float: left;
margin: 4px 35px 0px 0px;
}
.nav_main ul ul li.icon:after {
background: url("../pic/icons/glyphicons-415-disk-save.png") no-repeat top left;
background-size: 15px;
float: right;
margin: 4px 0px 0px 35px;
}
.nav_main ul ul li>img.before,
.nav_main ul ul li>img.after {
display: inline-block;
margin: 4px 35px 0px 0px;
width: 15px;
height: auto;
}
.nav_main ul ul li>img.before {
float: left;
margin: 4px 35px 0px 0px;
}
.nav_main ul ul li>img.after {
float: right;
margin: 4px 0px 0px 35px;
}
.nav_main ul ul li:hover {
background: #444;
background-image: linear-gradient(#04acec, #0186ba);
background-color: #0186ba;
display: inline-block;
margin: 0px;
padding: 5px 15px;
min-width: 185px;
min-height: 35px;
}
.nav_main ul ul li:first-child:hover {
border-radius: 3px 3px 0px 0px;
}
.nav_main ul ul li:last-child:hover {
border-radius: 0px 0px 3px 3px;
}
.nav_main ul ul li {
border: none;
box-shadow: none;
text-align: left;
display: inline-block;
flex: 0 0 auto;
margin: 0px;
padding: 5px 15px;
min-width: 185px;
min-height: 35px;
}
.nav_main ul ul li>a:hover {
color: #fafafa;
}
.nav_main ul ul li>a {
font: bold 12px Arial, Helvetica;
text-transform: uppercase;
text-decoration: none;
text-shadow: 0 1px 0 #000;
color: #999;
}
.nav_main ul ul li:hover>ul {
visibility: visible;
opacity: 1;
margin: 0;
}
<!-- Main Navigation (Container for JavaScript Function)-->
<div id="Navigation" class="navigation">
<!-- ### Main Navigation Link Liste ### -->
<nav id="Nav_Main" class="nav_main">
<ul class="flex-box">
<li>
Home
<ul class="flex-box">
<li>
Referenzen
</li>
<li>
Downloads
</li>
<li>
Partner Programm
</li>
<li>
Existenzgründer
</li>
<li>
<!-- Philosophie -->
Philosophie
</li>
</ul>
</li>
<li>
Hosting
<ul class="flex-box">
<li>
Web Hosting
</li>
<li>
TYPO3
</li>
<li>
WordPress
</li>
<li>
Magento
</li>
<li>
PrestaShop
</li>
</ul>
</li>
<li>
<a class="ajaxy" href="webdesign.html">WebDesign</a>
</li>
</ul>
</nav>
<!-- ### Main Navigation Link Liste End ### -->
</div>
<!-- Main Navigation Container End -->
Inside your flex-box class you can add a margin-left: -35px; and it will fix the position of the sub menu according to the snippet. You should mention though, that this might cause problems for the responsive part of your site.
I have to build a website for school and I am having trouble with a div class.
I wanted a new div for blog posts but it doesn't seem to work. If you take a look at my css you see that I changed the height but the text didn't move down. I called the div class 'first' and wrote some text to see where it would end up.
body {}
/*---- website---*/
#header {
position: relative;
top: 10px;
left: 0px;
font-size: 25px;
font-family: Lucida Console;
color: white;
background-color: #98AFC7;
width: 100%;
height: 50px;
padding: 20px 0px 10px 0px;
}
/*----lost een bug op die li en ul laat verdwijnen----*/
.clearfix:after {
display: block;
clear: both;
}
/*----- Menu -----*/
.menu-wrap {
position: relative;
left: 120px;
top: 0px;
width: 100%;
box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.2);
}
.menu {
width: 1000px;
margin: 30px auto;
}
.menu li {
margin: 0px;
list-style: none;
font-family: 'Ek Mukta';
}
.menu a {
transition: all linear 0.15s;
color: #D7D7D7;
}
.menu li:hover>a,
.menu .current-item>a {
text-decoration: none;
color: #fff;
}
.menu .arrow {
font-size: 11px;
line-height: 0%;
}
/*----- basis menu -----*/
.menu>ul>li {
float: left;
display: inline-block;
position: relative;
font-size: 19px;
}
.menu>ul>li>a {
padding: 10px 40px;
display: inline-block;
text-shadow: 0px 1px 0px rgba(0, 0, 0, 0.4);
}
.menu>ul>li:hover>a,
.menu>ul>.current-item>a {
background: #70879F;
}
/*-----2e menu-----*/
.menu li:hover .sub-menu {
z-index: 1;
opacity: 1;
}
.sub-menu {
width: 160%;
padding: 5px 0px;
position: absolute;
top: 100%;
left: 0px;
opacity: 0;
transition: opacity linear 0.15s;
box-shadow: 0px 2px 3px rgba(0, 0, 0, 0.2);
background: #70879F;
}
.sub-menu li {
display: block;
font-size: 16px;
}
.sub-menu li a {
padding: 10px 30px;
display: block;
}
.sub-menu li a:hover,
.sub-menu .current-item a {
background: #98AFC7;
}
.first {
margin: 600px 0px 0px 0px;
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="Home.css">
</head>
<body>
<div class="first">
tekst-tekst
</div>
<div id="header">
<center><big>No strings attached</big></center>
</div>
<!--menu-->
<div class="menu-wrap">
<nav class="menu">
<ul class="clearfix">
<li>Home</li>
<li class="current-item">Blog</li>
<li>
Webshop <span class="arrow">▼</span>
<ul class="sub-menu">
<li>Gitaren</li>
<li>Electronica</li>
<li>Overig</li>
<li>Sale</li>
</ul>
</li>
<li>Contact</li>
<li>Over mij</li>
</ul>
</nav>
</div>
</body>
</html>
Here is the coding what I have provided this one. This is for responsive design. When I click the logo, it didn't want to hide or show.
.toggle-nav {
display: none;
}
.menu {
float: right;
}
.menu ul {
display: inline-block;
}
.menu li {
float: left;
list-style: none;
font-size: 17px;
text-align: right;
}
.menuLink a {
font-size: 20px;
color: #FFF;
margin: 20px;
padding: 10px;
text-decoration: none;
float: left;
font-family: 'alegreya_sansregular';
cursor: pointer;
}
.menuLink a:hover,
.menu .current-item a {
border-bottom: 4px double #FFF;
}
.fixedPosition {
position: fixed !important;
top: 0;
left: 0;
}
#media only screen and (max-width: 820px) {
.menu {
position: relative;
display: inline-block;
}
.menu ul.active {
display: none;
}
.menu ul {
width: 100%;
position: absolute;
top: 90%;
left: -55px;
padding: 10px 18px;
box-shadow: 0px 1px 1px rgba(0, 0, 0, 0.15);
border-radius: 3px;
background: #cecece;
}
.menu ul:after {
width: 0px;
height: 0px;
position: absolute;
top: 0%;
left: 87px;
content: '';
transform: translate(0%, -100%);
border-left: 7px solid transparent;
border-right: 7px solid transparent;
border-bottom: 7px solid #cecece;
}
.menu li {
margin: 5px 0px;
float: none;
display: inline-block;
}
.menuLink a {
display: block;
font-size: 15px;
margin: 10px 0;
padding: 5px 0;
float: none;
}
.menuLink a:hover,
.menu .current-item a {
border-bottom: none;
color: #666;
}
.toggle-nav {
padding: 20px;
float: left;
display: inline-block;
box-shadow: 0px 1px 1px rgba(0, 0, 0, 0.15);
border-radius: 3px;
background: #cecece;
color: #777;
font-size: 20px;
transition: color linear 0.15s;
}
a.toggle-nav {
padding: 10px;
margin: 20px;
}
.toggle-nav:hover,
.toggle-nav.active {
color: #C3c3c3;
border-bottom: none;
position: relative;
}
}
<nav class="menu">
<ul class="menuLink">
<li> <a class="link-nav" data-scroll-nav="0"> HOME </a>
</li>
<li> WORKS
</li>
<li> <a data-scroll-nav="2"> ABOUT </a>
</li>
<li> <a data-scroll-nav="3"> CONTACT </a>
</li>
</ul>
<a class="toggle-nav" href="#">☰</a>
</nav>
Here is JSFIDDLE.
Before I click, the menu is staying there and doesn't want to hide. What I want is the menu has to hide at first before I click the logo. And also the menu can hide back after click the logo when it's showing. Any idea?
just use this jquery
$('.toggle-nav').click(function(){
$(this).parent().find('.menuLink').toggle();
});
FIDDLE
Here is my example with expanding and animated menues.
https://jsfiddle.net/9bn5t0kj/8/
$('.menu-header').on('click', function() {
$(this).next().toggleClass('menu-item-open');
$('.menu-item').not($(this).next()).removeClass('menu-item-open');
});
$(document).on('click', function(e) {
var clickedItem = $(e.target);
if (clickedItem.is($('.menu-header')) || clickedItem.is($('.menu-item'))) {
console.log(clickedItem);
return;
}
$('.menu-item').removeClass('menu-item-open');
});
.menu-item-container {
float: left;
}
.menu-header {
-webkit-user-select: none;
cursor: pointer;
}
.menu-item {
height: 0;
overflow: hidden;
-webkit-transition: height .25s;
}
.menu-item-open {
height: 200px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="menu">
<div class="menu-item-container">
<div class="menu-header">Open 1</div>
<div class="menu-item">
Hej hopp!<br>
Hej hopp!<br>
Hej hopp!<br>
Hej hopp!<br>
Hej hopp!<br>
</div>
</div>
<div class="menu-item-container">
<div class="menu-header">Open 2</div>
<div class="menu-item">
Hej hopp 2!<br>
Hej hopp 2!<br>
Hej hopp 2!<br>
Hej hopp 2!<br>
Hej hopp 2!<br>
</div>
</div>
You can hide it by default with jQuery .hide() and show it when .toggle-nav is clicked. it's pretty simple.
$(document).ready(function() {
$('.menuLink').hide();
$('.toggle-nav').click(function() {
$('.menuLink').toggle();
});
});
.toggle-nav {
display: none;
}
.menu {
float: right;
}
.menu ul {
display: inline-block;
}
.menu li {
float: left;
list-style: none;
font-size: 17px;
text-align: right;
}
.menuLink a {
font-size: 20px;
color: #FFF;
margin: 20px;
padding: 10px;
text-decoration: none;
float: left;
font-family: 'alegreya_sansregular';
cursor: pointer;
}
.menuLink a:hover,
.menu .current-item a {
border-bottom: 4px double #FFF;
}
.fixedPosition {
position: fixed !important;
top: 0;
left: 0;
}
#media only screen and (max-width: 820px) {
.menu {
position: relative;
display: inline-block;
}
.menu ul.active {
display: none;
}
.menu ul {
width: 100%;
position: absolute;
top: 90%;
left: -55px;
padding: 10px 18px;
box-shadow: 0px 1px 1px rgba(0, 0, 0, 0.15);
border-radius: 3px;
background: #cecece;
}
.menu ul:after {
width: 0px;
height: 0px;
position: absolute;
top: 0%;
left: 87px;
content: '';
transform: translate(0%, -100%);
border-left: 7px solid transparent;
border-right: 7px solid transparent;
border-bottom: 7px solid #cecece;
}
.menu li {
margin: 5px 0px;
float: none;
display: inline-block;
}
.menuLink a {
display: block;
font-size: 15px;
margin: 10px 0;
padding: 5px 0;
float: none;
}
.menuLink a:hover,
.menu .current-item a {
border-bottom: none;
color: #666;
}
.toggle-nav {
padding: 20px;
float: left;
display: inline-block;
box-shadow: 0px 1px 1px rgba(0, 0, 0, 0.15);
border-radius: 3px;
background: #cecece;
color: #777;
font-size: 20px;
transition: color linear 0.15s;
}
a.toggle-nav {
padding: 10px;
margin: 20px;
}
.toggle-nav:hover,
.toggle-nav.active {
color: #C3c3c3;
border-bottom: none;
position: relative;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<nav class="menu">
<ul class="menuLink">
<li> <a class="link-nav" data-scroll-nav="0"> HOME </a>
</li>
<li> WORKS
</li>
<li> <a data-scroll-nav="2"> ABOUT </a>
</li>
<li> <a data-scroll-nav="3"> CONTACT </a>
</li>
</ul>
<a class="toggle-nav" href="#">☰</a>
</nav>
I want to make my navbar directly in the middle of the page. So as i scroll down the rest of my content appears from beneath. Could someone please help and also explain how to position my background image to fixed so as i scroll the background doesn't move and lose its quality in resolution.
.menu-wrap {
width: 750px;
margin: 0 auto;
list-style: none;
}
/* DROPDOWN */
.ulMenu {
padding: 0;
margin: 0;
}
.navMenu ul {
padding: 0;
margin: 0;
line-height: 30px;
}
navMenu {
padding: 0;
margin: 0;
}
.navMenu li {
list-style-type: none;
padding: 0;
margin: 0;
float: left;
position: relative;
}
.navMenu ul li a {
text-align: center;
padding: 10px;
width: 150px;
height: 30px;
display: block;
color: white;
background-color: rgba(233, 233, 233, 0.5);
text-decoration: none;
border-radius: 0px;
font-family: 'Raleway', sans-serif;
font-size: 20px;
}
.navMenu ul ul {
position: absolute;
visibility: hidden;
}
.navMenu ul li:hover ul {
visibility: visible;
}
.ulMenu .arrow {
font-size: 10px;
}
.navMenu ul li:hover ul li a:hover {
background-color: rgba(93, 93, 93, 0.5);
}
.navMenu li:hover {
background-color: none;
}
.navMenu a:hover {
color: blue;
}
.navMenu ul li ul li {
padding: 2px 0 0 0;
}
.navMenu ul li {
padding: 0 2px 0 0;
}
/* DROPDOWN ENDED */
html {
background-image: url("indexImg.jpg");
background-size: cover;
}
<div class="menu-wrap">
<nav class="navMenu">
<ul class="ulMenu">
<li>Home
</li>
<li>
Products<span class="arrow">▼</span>
<ul>
<li>#
</li>
<li>#
</li>
</ul>
</li>
<li>Contact Us
</li>
<li>About
</li>
</ul>
</nav>
</div>
.menu-wrap {
position: relative;
}
.navMenu {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
I hope this is what u need
Check if it could complete your code
HTML
<nav>
<ul class="nav">
<li>Home</li>
<li>Product
<ul>
<li>item</li>
<li>item</li>
<li>item</li>
<li>item</li>
</ul>
</li>
<li>Contact us
<li>About</li>
CSS
nav {
display: block;
text-align: center;
}
nav ul {
margin: 0;
padding:0;
list-style: none;
}
.nav a {
display:block;
background: #111;
color: #fff;
text-decoration: none;
padding: 0.8em 1.8em;
text-transform: uppercase;
font-size: 80%;
letter-spacing: 2px;
text-shadow: 0 -1px 0 #000;
position: relative;
}
.nav{
vertical-align: top;
display: inline-block;
box-shadow:
1px -1px -1px 1px #000,
-1px 1px -1px 1px #fff,
0 0 6px 3px #fff;
border-radius:6px;
}
.nav li {
position: relative;
}
.nav > li {
float: left;
border-bottom: 4px #aaa solid;
margin-right: 1px;
}
.nav > li > a {
margin-bottom: 1px;
box-shadow: inset 0 2em .33em -0.5em #555;
}
.nav > li:hover,
.nav > li:hover > a {
border-bottom-color: orange;
}
.nav li:hover > a {
color:orange;
}
.nav > li:first-child {
border-radius: 4px 0 0 4px;
}
.nav > li:first-child > a {
border-radius: 4px 0 0 0;
}
.nav > li:last-child {
border-radius: 0 0 4px 0;
margin-right: 0;
}
.nav > li:last-child > a {
border-radius: 0 4px 0 0;
}
.nav li li a {
margin-top: 1px;
}
.nav li a:first-child:nth-last-child(2):before {
content: "";
position: absolute;
height: 0;
width: 0;
border: 5px solid transparent;
top: 50% ;
right:5px;
}
.nav ul {
position: absolute;
white-space: nowrap;
border-bottom: 5px solid orange;
z-index: 1;
left: -99999em;
}
.nav > li:hover > ul {
left: auto;
margin-top: 5px;
min-width: 100%;
}
.nav > li li:hover > ul {
left: 100%;
margin-left: 1px;
top: -1px;
}
/* arrow hover styling */
.nav > li > a:first-child:nth-last-child(2):before {
border-top-color: #aaa;
}
.nav > li:hover > a:first-child:nth-last-child(2):before {
border: 5px solid transparent;
border-bottom-color: orange;
margin-top:-5px
}
.nav li li > a:first-child:nth-last-child(2):before {
border-left-color: #aaa;
margin-top: -5px
}
.nav li li:hover > a:first-child:nth-last-child(2):before {
border: 5px solid transparent;
border-right-color: orange;
right: 10px;
}
I was able to successfully create a navigation menu with a submenu that appears on hover. However, I would like my submenus to have columns. I used Vanga Sasidhar's tips on creating the hover nav, I now need to create the columns under the Solutions and Support menu items.
Here is my jsfiddle: http://jsfiddle.net/DKu7p/.
Here is my CSS:
.site-nav li {
display:block;
float:left;
list-style:none;
margin: 0;
position: relative;
width: 100px;
}
.site-nav li:hover {
background:#1f78c3;
cursor:pointer;
}
.site-nav li a {
color:#696969;
display:block;
text-align:center;
text-decoration:none;
padding:5px 10px;
}
.site-nav li a:hover {
color:#00598B;
display:block;
text-align:center;
text-decoration:none;
padding:5px 10px;
}
.site-nav .dropdown {
display : none;
position : relative;
}
.site-nav .dropdown li { float : none; }
.site-nav li:hover .dropdown { display : block; position: relative; }
.dropdown {
background: #fff;
border: 1px solid #fff;
border-top: 0;
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
box-shadow: 0 1px 5px rgba(0, 0, 0, 0.35);
list-style: none;
margin: 4px 0 0 -9px;
min-width: 150px;
overflow: hidden;
padding: 0;
position: relative;
z-index: 999;
}
.dropdown li {
border: 0;
border-radius: 0;
clear: both;
float: none;
font-size: .9em;
margin: 0;
width: 100%;
}
.dropdown li span {
display: none !important;
}
.dropdown li a {
background: none;
color: #333;
display: block;
font-size: 1.1em;
font-weight: normal;
padding: 5px 8px;
text-align: left;
text-shadow: none;
}
.dropdown li a:hover {
background: #ddd;
color: #0c84bb;
text-decoration: none;
}
.dropdown .last a {
border-bottom: none;
}
Ok, here my try:
Apply the three column css layout
.col-columned{
width: 450px;
}
.col-maincontainer{
width: 450px; /*Width of main container*/
margin: 0 auto; /*Center container on page*/
}
.col-maincontainer ul, .col-maincontainer ul{
margin: 0;
padding: 0;
list-style-type: none;
}
.col-contentwrapper{
float: left;
width: 100%;
}
.col-contentcolumn{
margin: 0 190px 0 180px; /*Margins for content column. Should be "0 RightColumnWidth 0 LeftColumnWidth*/
}
.col-leftcolumn{
float: left;
width: 150px; /*Width of left column in pixel*/
margin-left: -450px; /*Set margin to that of -(MainContainerWidth)*/
background: #C8FC98;
}
.col-rightcolumn{
float: left;
width: 150px; /*Width of right column*/
margin-left: -150px; /*Set left margin to -(RightColumnWidth)*/
background: #FDE95E;
}
.col-innertube{
margin: 3px; /*Margins for inner DIV inside each column (to provide padding)*/
margin-top: 0;
}
And then, add a new element with the html markout of three columns:
<a class="drop-link">Example1</a>
<ul class="dropdown col-columned">
<li>
<div class="col-maincontainer">
<div class="col-contentwrapper">
<div class="col-contentcolumn">
<div class="col-innertube">
<div class="wiki-tree">
<ul>
<li><a class="dropdown-title">topic1</a></li>
<li><a class="dropdown-title">topic2</a></li>
<li><a class="dropdown-title">topic3</a></li>
</ul>
</div>
</div>
</div>
</div>
<div class="col-leftcolumn">
<div class="col-innertube">
<div class="wiki-tree">
<ul>
<li><a class="dropdown-title">topic1</a></li>
<li><a class="dropdown-title">topic2</a></li>
<li><a class="dropdown-title">topic3</a></li>
</ul>
</div>
</div>
</div>
<div class="col-rightcolumn">
<div class="col-innertube">
<div class="wiki-tree">
<ul>
<li><a class="dropdown-title">topic1</a></li>
<li><a class="dropdown-title">topic2</a></li>
<li><a class="dropdown-title">topic3</a></li>
</ul>
</div>
</div>
</div>
</div>
</li>
</ul>
Make sure to add the col-columned to the dropdown element like this:
<ul class="dropdown col-columned">
Here the live example: http://jsfiddle.net/8fgG5/1/