How can I use the same CSS for 2 divs? - html

I have the 2 divs that I want styled the same. One is called #popover, the other is called #recordViewPopover. Here is my CSS for popover. How can I make #recordViewPopover use the same CSS as #popover?
#popover {
-webkit-border-radius: 4px;
-webkit-box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
-webkit-transition: opacity 0.25s linear;
-moz-border-radius: 4px;
-moz-box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
-moz-transition: opacity 0.25s linear;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
transition: opacity 0.25s linear;
border: 3px solid black;
border-radius: 4px;
background-color: white;
color: black;
cursor: auto;
display: none;
font-weight: normal;
line-height: 1;
position: absolute;
right: 22px;
z-index: 5000000;
}
#popover > .popover_triangle
{
border-top: 16px solid rgba(0,0,0,0);
border-left: 16px solid rgba(0,0,0,0);
border-right: 16px solid rgba(0,0,0,0);
border-bottom: 16px solid black;
font-size: 0px;
line-height: 0%;
position: absolute;
top: -34px;
left:150px;
width: 0px;
}
#popover > .header
{
background: #222;
background: -moz-linear-gradient(top, #333 0%, #111 100%);
background-image: -webkit-gradient(
linear,
left top,
left bottom,
from(rgba(255, 255, 255, 0.55)),
color-stop(0.2, rgba(255, 255, 255, 0.35)),
color-stop(0.5, rgba(255, 255, 255, 0.1)),
color-stop(0.5, transparent),
to(transparent));
color: white;
font-weight: bold;
height: 27px;
line-height: 25px;
margin: 0;
padding: 3px;
text-shadow: rgba(0, 0, 0, 1) 0 -1px 0;
text-align: center;
}
#popover > .content
{
font-size: 12px;
max-height: 400px;
overflow-x: hidden;
overflow-y: auto;
width: 190px;
}
#popover > .content ul
{
list-style: none;
margin: 0;
padding: 0;
}
#popover > .content ul li
{
border-bottom: #ccc 1px solid;
line-height: 25px;
}
#popover > .content ul li.item:hover
{
border-bottom: #1443be 1px solid;
}
#popover > .content ul li h6
{
background: #f3f3f3;
display: block;
color: #000;
font-size: 13px;
padding: 0 10px;
text-shadow: rgba(255, 255, 255, 1) 0 -1px 0;
}
#popover > .content ul li a
{
display: block;
padding: 0 14px;
}
#popover > .content ul li a:link,
#popover > .content ul li a:visited
{
text-decoration:none;color:#333;
}
#popover > .content ul li a:focus,
#popover > .content ul li a:hover
{
background: #5396e3 url('../images/arrow-small.png') 97% center no-repeat;
color: #fff;
text-decoration: none;
text-shadow: rgba(0, 0, 0, .55) 0 -1px 0;
}
Here are my divs
<div id='popover'>
<div class='popover_triangle'></div>
<div class='header'>OPTIONS</div>
<div class='content'>
<ul>
<li><h6>OBJECT VIEW</h6></li>
<li class='item'><a onclick=\"$(document).trigger('objectViewFiltersEnabled', [ !filtersEnabled ]);\">Filters</a></li>
<li class='item'><a href=\"#\" >Configuration</a></li>
<li><h6>OBJECT</h6></li>
<li class='item'><a href=\"#\" >Configuration</a></li>
<li class='item'><a href=\"#\" >Documentation</a></li>
</ul>
</div>
</div>
<div id='recordViewPopover'>
<div class='popover_triangle'></div>
<div class='header'>OPTIONS</div>
<div class='content'>
<ul>
<li><h6>Information</h6></li>
<li class='item'><a href='#' >Change Logs</a></li>
<li><h6>Actions</h6></li>
<li class='item'><a href='#' >Assign</a></li>
<li class='item'><a href='#' >Share</a></li>
<li class='item'><a href='#' >Convert</a></li>
<li class='item'><a href='#' >Copy</a></li>
<li class='item'><a href='#' >Clone</a></li>
<li class='item'><a href='#' >Merge</a></li>
<li class='item'><a href='#' >Refresh</a></li>
<li class='item'><a href='#' >Delete</a></li>
</ul>
</div>
</div>

You would assign them both the same class. To do this you would have:
<div id='popover' class='someName'>
<div id='recordViewPopover' class='someName'>
and your CSS would be declared:
.someName {
//Add styles here
}

You could group multiple selectors:
#popover > .popover_triangle,
#recordViewPopover > .popover_triangle {
Or give the elements a class, and use a class selector where you have the id selector.
.popover > .popover_triangle {

#popover, #recordViewPopover {
...
}
Oh, and also
#popover > .popover_triangle,
#recordViewPopover > .popover_triangle {
...
}
But if you expect to have more divs like these two, it would indeed be better to define a class for them.

Related

How to center "position: relative"-navigation bar?

How can I center a navigation bar with the position property set to relative? It's for this website.
I've found several solutions for doing that, but that requires me to change the position of the navigation bar to absolute. I can't do that, since that ruins the entiry css style for the navigation bar!
body header .bottom-header {
border-radius: 15px 0 0 0;
width: 100%;
height: 125px;
background: linear-gradient(to right, #381107, #993013, #FF5221);
text-align: center;
}
body header .bottom-header ul {
position: relative;
top: 32%;
list-style-type: none;
margin: 0;
padding: 0;
}
body header .bottom-header ul li a {
transition: all .4s ease;
color: rgba(255, 255, 255, 0.4);
text-decoration: none;
text-transform: uppercase;
font-weight: bold;
font-size: 14px;
}
body header .bottom-header .button {
transition: all .4s ease;
display: block;
float: left;
top: 40px;
margin: auto;
min-width: 13%;
max-width: 13%;
padding-top: 8px;
padding-bottom: 8px;
border: 2px solid rgba(255, 255, 255, 0.4);
border-radius: 12px;
margin-left: 0.4%;
margin-right: 0.4%;
cursor: pointer;
}
body header .bottom-header .button:hover {
border: 2px solid rgba(255, 255, 255, 0.7);
}
body header .bottom-header .button:hover a {
color: rgba(255, 255, 255, 0.7);
}
<center>
<div class="bottom-header">
<ul>
<li class="button" id="top" style="margin-left: 1%;" onclick="window.location='hem.html';">Hem</li>
<li class="button" id="top" onclick="window.location='om.html';">Om Mango</li>
<li class="button" id="top" onclick="window.location='filosofi.html';">Filosofi</li>
<li class="button" id="top" onclick="window.location='personal.html';">Personal</li>
<li class="button" id="bottom-start" onclick="window.location='kontakt.html';">Kontakt</li>
<li class="button" id="bottom" onclick="window.location='hitta-hit.html';">Hitta hit</li>
<li class="button" id="bottom" onclick="window.location='bostaderna.html';">Verksamheterna</li>
</ul>
</div>
</center>
What I've done to center it (which really isn't a good solution) is, I change the margin on each side of the navigation bar depending on the total width of the page. Like you can see if you take a look at the css of the page i linked before. Thank you!
Make yout ul a relatively positioned inline-blockand use margin: 0 auto; on it to center it. And erase all width settings from the lielements / buttons, so they can have the width necessary for their text contents:
.bottom-header {
border-radius: 15px 0 0 0;
width: 100%;
background: linear-gradient(to right, #381107, #993013, #FF5221);
text-align: center;
}
.bottom-header ul {
position: relative;
display: inline-block;
margin: 0 auto;
list-style-type: none;
padding: 0;
}
.bottom-header ul li a {
transition: all .4s ease;
color: rgba(255, 255, 255, 0.4);
text-decoration: none;
text-transform: uppercase;
font-weight: bold;
font-size: 14px;
}
.bottom-header .button {
transition: all .4s ease;
display: block;
top: 40px;
padding-top: 8px;
padding-bottom: 8px;
border: 2px solid rgba(255, 255, 255, 0.4);
border-radius: 12px;
cursor: pointer;
}
.bottom-header .button:hover {
border: 2px solid rgba(255, 255, 255, 0.7);
}
.bottom-header .button:hover a {
color: rgba(255, 255, 255, 0.7);
}
<div class="bottom-header">
<ul>
<li class="button" id="top" onclick="window.location='hem.html';">Hem</li>
<li class="button" id="top" onclick="window.location='om.html';">Om Mango</li>
<li class="button" id="top" onclick="window.location='filosofi.html';">Filosofi</li>
<li class="button" id="top" onclick="window.location='personal.html';">Personal</li>
<li class="button" id="bottom-start" onclick="window.location='kontakt.html';">Kontakt</li>
<li class="button" id="bottom" onclick="window.location='hitta-hit.html';">Hitta hit</li>
<li class="button" id="bottom" onclick="window.location='bostaderna.html';">Verksamheterna</li>
</ul>
</div>
In case you want the buttons aligned horzontally (i.e. other than in the code you posted), apple diplay: inline-block to the lielements, and maybe a fixed min-width setting:
.bottom-header {
border-radius: 15px 0 0 0;
width: 100%;
background: linear-gradient(to right, #381107, #993013, #FF5221);
text-align: center;
}
.bottom-header ul {
position: relative;
display: inline-block;
margin: 0 auto;
list-style-type: none;
padding: 0;
}
.bottom-header ul li a {
transition: all .4s ease;
color: rgba(255, 255, 255, 0.4);
text-decoration: none;
text-transform: uppercase;
font-weight: bold;
font-size: 14px;
}
.bottom-header .button {
transition: all .4s ease;
display: inline-block;
min-width: 90px;
top: 40px;
padding-top: 8px;
padding-bottom: 8px;
border: 2px solid rgba(255, 255, 255, 0.4);
border-radius: 12px;
cursor: pointer;
}
.bottom-header .button:hover {
border: 2px solid rgba(255, 255, 255, 0.7);
}
.bottom-header .button:hover a {
color: rgba(255, 255, 255, 0.7);
}
<div class="bottom-header">
<ul>
<li class="button" id="top" onclick="window.location='hem.html';">Hem</li>
<li class="button" id="top" onclick="window.location='om.html';">Om Mango</li>
<li class="button" id="top" onclick="window.location='filosofi.html';">Filosofi</li>
<li class="button" id="top" onclick="window.location='personal.html';">Personal</li>
<li class="button" id="bottom-start" onclick="window.location='kontakt.html';">Kontakt</li>
<li class="button" id="bottom" onclick="window.location='hitta-hit.html';">Hitta hit</li>
<li class="button" id="bottom" onclick="window.location='bostaderna.html';">Verksamheterna</li>
</ul>
</div>

Adjust gap between menu

I'm trying to adjust the spacing(gap) between menu so it'll fit with the navbar.By changing margin doesn't seems to do it. Anyone have idea on how to fix this ? Is it possible to re-position each menu individually ?
Here's the demo
#navbar {
width: 1200px;
height: 180px;
background: url(http://i67.tinypic.com/5cygax.png) no-repeat center center;
background-size: contain;
-webkit-background-size: contain;
-moz-background-size: contain;
-o-background-size: contain;
background-size: contain;
margin-left: 80px;
margin-top: 100px;
}
#menu {
display: inline-block;
margin: 65px 50px 0px 100px;
position: relative;
float: left;
width: 100px;
padding: 0 10px;
border-radius: 8px;
box-shadow: inset 0 1px 1px rgba(255, 255, 255, .5), inset 0 -1px 0 rgba(0, 0, 0, .15), 0 1px 3px rgba(0, 0, 0, .15);
background: #8495F5;
}
#menu,
#menu ul {
list-style: none;
}
#menu: li {
float: left;
position: relative;
border-right: 1px solid rgba(0, 0, 0, .1);
box-shadow: 1px 0 0 rgba(255, 255, 255, .25);
perspective: 1000px;
}
#menu: li:first-child {
border-left: 1px solid rgba(255, 255, 255, .25);
box-shadow: -1px 0 0 rgba(0, 0, 0, .1), 1px 0 0 rgba(255, 255, 255, .25);
}
#menu a {
display: block;
position: inherit;
z-index: 10;
padding: 15px 20px 15px 20px;
text-decoration: none;
color: rgba(75, 75, 75, 1);
line-height: 1;
font-family: sans-serif;
font-weight: 700;
font-size: 12px;
letter-spacing: 0.15em;
background: transparent;
text-shadow: 0 1px 1px rgba(255, 255, 255, .9);
transition: all .25s ease-in-out;
text-align: center;
}
#menu: li:hover>a {
background: #333;
color: rgba(0, 223, 252, 1);
text-shadow: none;
}
#menu li ul {
position: absolute;
left: 0;
z-index: 1;
width: 250px;
padding: 0;
opacity: 0;
visibility: hidden;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
background: transparent;
overflow: hidden;
transform-origin: 50% 0%;
}
#menu li:hover ul {
padding: 5px 0;
background: #333;
opacity: 1;
visibility: visible;
box-shadow: 1px 1px 7px rgba(0, 0, 0, .5);
animation-name: swingdown;
animation-duration: 1s;
animation-timing-function: ease;
}
#keyframes swingdown {
0% {
opacity: .99999;
transform: rotateX(90deg);
}
30% {
transform: rotateX(-20deg) rotateY(5deg);
animation-timing-function: ease-in-out;
}
65% {
transform: rotateX(20deg) rotateY(-3deg);
animation-timing-function: ease-in-out;
}
100% {
transform: rotateX(0);
animation-timing-function: ease-in-out;
}
}
#menu li li a {
padding-left: 15px;
font-weight: 400;
color: #ddd;
text-shadow: none;
border-top: dotted 1px transparent;
border-bottom: dotted 1px transparent;
transition: all .15s linear;
}
#menu li li a:hover {
color: rgba(0, 223, 252, 1);
border-top: dotted 1px rgba(255, 255, 255, .15);
border-bottom: dotted 1px rgba(255, 255, 255, .15);
background: rgba(0, 223, 252, .02);
}
<div id="container">
<div id="navbar">
<ul id="menu">
<li><a class="home" href="#">Home</a></li>
</ul>
<ul id="menu">
<li><a class="register" href="#">Register</a></li>
</ul>
<ul id="menu">
<li><a class="guide" href="#">Guide</a>
<ul>
<li>New Features</li>
<li>Quest & Event Guide</li>
<li>Brigand & T-map Guide</li>
</ul>
</ul>
<ul id="menu">
<li><a class="download" href="#">Download</a>
<ul>
<li>Patch Download</li>
</ul>
</ul>
</div>
</div>
I am guessing you want something like this?
The last lines in the CSS will control each LI position.
SOURCE:
#navbar{
width: 1200px;
height: 180px;
background: url(http://i67.tinypic.com/5cygax.png) no-repeat center center;
background-size: contain;
-webkit-background-size: contain;
-moz-background-size: contain;
-o-background-size: contain;
background-size: contain;
margin-left: 80px;
margin-top: 100px;
}
ul#menu {
display: inline-block;
margin: 65px 0 0px 195px;
position: relative;
width: 800px;
list-style-type:none;
}
ul#menu, ul#menu-sub {
list-style-type: none;
}
ul#menu > li {
padding: 0 10px;
box-shadow: inset 0 1px 1px rgba(255,255,255,.5), inset 0 -1px 0 rgba(0,0,0,.15), 0 1px 3px rgba(0,0,0,.15);
background: #8495F5;
width: 100px;
float: left;
position: relative;
display: inline-block;
border-right: 1px solid rgba(0,0,0,.1);
box-shadow: 1px 0 0 rgba(255,255,255,.25);
border-radius: 8px;
}
#menu li:first-child {
border-left: 1px solid rgba(255,255,255,.25);
box-shadow: -1px 0 0 rgba(0,0,0,.1), 1px 0 0 rgba(255,255,255,.25);
}
#menu a.menu-top {
display: block;
position: inherit;
z-index: 10;
padding: 15px 20px 15px 20px;
text-decoration: none;
color: rgba(75,75,75,1);
line-height: 1;
font-family: sans-serif;
font-weight: 700;
font-size: 12px;
letter-spacing: 0.15em;
background: transparent;
text-shadow: 0 1px 1px rgba(255,255,255,.9);
transition: all .25s ease-in-out;
text-align: center;
}
#menu-sub {
position: absolute;
left: 0;
z-index: 1;
width: 250px;
padding: 0;
opacity: 0;
visibility: hidden;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
background: transparent;
overflow: hidden;
transform-origin: 50% 0%;
}
#menu-sub a {
padding-left: 15px;
font-weight: 400;
color: #ddd;
text-shadow: none;
border-top: dotted 1px transparent;
border-bottom: dotted 1px transparent;
transition: all .15s linear;
padding: 10px;
display:block;
}
#menu-sub a:hover {
color: rgba(0,223,252,1);
border-top: dotted 1px rgba(255,255,255,.15);
border-bottom: dotted 1px rgba(255,255,255,.15);
background: rgba(0,223,252,.02);
}
#menu-sub li:hover > a {
background: #333;
color: rgba(0,223,252,1);
text-shadow: none;
}
#menu li:hover #menu-sub {
padding: 5px 0;
background: #333;
opacity: 1;
visibility: visible;
box-shadow: 1px 1px 7px rgba(0,0,0,.5);
animation-name: swingdown;
animation-duration: 1s;
animation-timing-function: ease;
}
#keyframes swingdown {
0% {
opacity: .99999;
transform: rotateX(90deg);
}
30% {
transform: rotateX(-20deg) rotateY(5deg);
animation-timing-function: ease-in-out;
}
65% {
transform: rotateX(20deg) rotateY(-3deg);
animation-timing-function: ease-in-out;
}
100% {
transform: rotateX(0);
animation-timing-function: ease-in-out;
}
}
/* controlling each li's position */
ul#menu li:nth-child(1) { /*first */
margin-right: 3%
}
ul#menu li:nth-child(2) { /*first */
margin-right: 200px;
}
ul#menu li:nth-child(3) { /*first */
margin-right: 3%
}
ul#menu li:nth-child(4) { /*first */
margin-right: 0;
}
<div id="container">
<div id="navbar">
<ul id="menu">
<li><a class="menu-top home" href="#">Home</a></li>
<li><a class="menu-top register" href="#">Register</a></li>
<li>
<a class="menu-top guide" href="#">Guide</a>
<ul id="menu-sub">
<li>New Features</li>
<li>Quest & Event Guide</li>
<li>Brigand & T-map Guide</li>
</ul>
</li>
<li>
<a class="menu-top download" href="#">Download</a>
<ul id="menu-sub">
<li>Patch Download</li>
</ul>
</li>
</ul>
</div>
</div>
View Pen: Adjust gap between menu
Changed margin for #menu
#menu {
margin: 65px 0 0px 20px;
}
#navbar {
width: 1200px;
height: 180px;
background: url(http://i67.tinypic.com/5cygax.png) no-repeat center center;
background-size: contain;
-webkit-background-size: contain;
-moz-background-size: contain;
-o-background-size: contain;
background-size: contain;
margin-left: 80px;
margin-top: 100px;
}
#menu {
display: inline-block;
margin: 65px 0 0px 20px;
position: relative;
float: left;
width: 100px;
padding: 0 10px;
border-radius: 8px;
box-shadow: inset 0 1px 1px rgba(255, 255, 255, .5), inset 0 -1px 0 rgba(0, 0, 0, .15), 0 1px 3px rgba(0, 0, 0, .15);
background: #8495F5;
}
#menu,
#menu ul {
list-style: none;
}
#menu: li {
float: left;
position: relative;
border-right: 1px solid rgba(0, 0, 0, .1);
box-shadow: 1px 0 0 rgba(255, 255, 255, .25);
perspective: 1000px;
}
#menu: li:first-child {
border-left: 1px solid rgba(255, 255, 255, .25);
box-shadow: -1px 0 0 rgba(0, 0, 0, .1), 1px 0 0 rgba(255, 255, 255, .25);
}
#menu a {
display: block;
position: inherit;
z-index: 10;
padding: 15px 20px 15px 20px;
text-decoration: none;
color: rgba(75, 75, 75, 1);
line-height: 1;
font-family: sans-serif;
font-weight: 700;
font-size: 12px;
letter-spacing: 0.15em;
background: transparent;
text-shadow: 0 1px 1px rgba(255, 255, 255, .9);
transition: all .25s ease-in-out;
text-align: center;
}
#menu: li:hover>a {
background: #333;
color: rgba(0, 223, 252, 1);
text-shadow: none;
}
#menu li ul {
position: absolute;
left: 0;
z-index: 1;
width: 250px;
padding: 0;
opacity: 0;
visibility: hidden;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
background: transparent;
overflow: hidden;
transform-origin: 50% 0%;
}
#menu li:hover ul {
padding: 5px 0;
background: #333;
opacity: 1;
visibility: visible;
box-shadow: 1px 1px 7px rgba(0, 0, 0, .5);
animation-name: swingdown;
animation-duration: 1s;
animation-timing-function: ease;
}
#keyframes swingdown {
0% {
opacity: .99999;
transform: rotateX(90deg);
}
30% {
transform: rotateX(-20deg) rotateY(5deg);
animation-timing-function: ease-in-out;
}
65% {
transform: rotateX(20deg) rotateY(-3deg);
animation-timing-function: ease-in-out;
}
100% {
transform: rotateX(0);
animation-timing-function: ease-in-out;
}
}
#menu li li a {
padding-left: 15px;
font-weight: 400;
color: #ddd;
text-shadow: none;
border-top: dotted 1px transparent;
border-bottom: dotted 1px transparent;
transition: all .15s linear;
}
#menu li li a:hover {
color: rgba(0, 223, 252, 1);
border-top: dotted 1px rgba(255, 255, 255, .15);
border-bottom: dotted 1px rgba(255, 255, 255, .15);
background: rgba(0, 223, 252, .02);
}
<div id="container">
<div id="navbar">
<ul id="menu">
<li><a class="home" href="#">Home</a></li>
</ul>
<ul id="menu">
<li><a class="register" href="#">Register</a></li>
</ul>
<ul id="menu">
<li><a class="guide" href="#">Guide</a>
<ul>
<li>New Features</li>
<li>Quest & Event Guide</li>
<li>Brigand & T-map Guide</li>
</ul>
</ul>
<ul id="menu">
<li><a class="download" href="#">Download</a>
<ul>
<li>Patch Download</li>
</ul>
</ul>
</div>
</div>

Responsive Dropdown Menu child li same width as longest li

i have this responsive dropdown menu. My question, is it possible that the child li elements have all the same width as the longest child li? If yes, what i have to edit?
I put my code on jsfiddle. The decisive part is at the bottom (WIDE: Nav).
http://jsfiddle.net/7qLmmswp/1/
HTML:
<nav id="twNav-s1" class="twNav twNav-vertical twNav-left">
<ul>
<li>
<div class="nav-sep"></div>
Blog
</li>
<li>
<div class="nav-sep"></div>
About
</li>
<li>
<div class="nav-sep"></div>
Media
<ul>
<li>
<div class="nav-sep"></div>
Stuff
</li>
<li>
<div class="nav-sep"></div>
StuffStuff
</li>
<li>
<div class="nav-sep"></div>
StuffStuffStuff
</li>
</ul>
</li>
<li>
<div class="nav-sep"></div>
Contact
</li>
<li>
<div class="nav-sep"></div>
</li>
</ul>
</nav>
CSS:
.twNav {
background: rgb(86,107,132);
-webkit-box-shadow: 13px 0px 51px -28px rgba(0,0,0,0.75), inset 13px 0px 51px -28px rgba(0,0,0,0.75);
-moz-box-shadow: 13px 0px 51px -28px rgba(0,0,0,0.75), inset 13px 0px 51px -28px rgba(0,0,0,0.75);
box-shadow: 13px 0px 51px -28px rgba(0,0,0,0.75), inset 13px 0px 51px -28px rgba(0,0,0,0.75);
border-right: 1px solid #8aa5c7;
position: fixed;
opacity: 0.97;
}
.twNav a {
display: block;
color: #fff;
font-size:13.5pt;
font-weight: 300;
text-decoration:none;
text-shadow: 0px 1px 1px rgba(0, 0, 0, 1);
}
.twNav a:hover {
background: #a8b4c4;
}
.twNav a:active {
background: #a2bada;
color: #e4a155;
}
.twNav ul {
margin-top:32px;
padding-left:3px;
padding-right:3px;
}
/* Orientation-dependent styles for the content of the menu */
.twNav-vertical {
width: 240px;
height: 100%;
top: 0;
z-index: 1000;
}
.twNav-vertical a {
border-bottom: 1px solid #8aa5c7;
padding: 0.6em;
}
/* Vertical menu that slides from the left */
.twNav-left {
left: -300px;
}
.twNav-left.twNav-open {
left: 0px;
}
.twNav-right.twNav-open {
right: 0px;
}
/* Transitions */
.twNav,
.twNav-push {
-webkit-transition: all 0.3s ease;
-moz-transition: all 0.3s ease;
transition: all 0.3s ease;
}
/* ==============
MOBILE: Menu
============== */
.menu-icon {
display:block;
width: 30px;
height: 30px;
background: url(../img/menu-icon.png);
background:#fff;
position:absolute;
right:20px;
top: 95px;
z-index:2;
}
.menu-icon:hover {
background-color: #444;
border-radius: 6px 6px 0 0;
}
#media only screen and (min-width: 640px) {
/* ====================
WIDE: Nav
==================== */
.menu-icon {
display: none;
}
.nav-sep {
background-image: url('../img/nav-sep.png');
width:7px;
height:30px;
float:left;
}
.twNav {
background: transparent;
position: absolute;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
border-right: 0;
opacity: 1;
}
.twNav-vertical {
width: 100%;
height: 50px;
top: 100px;
z-index: 1000;
}
.twNav-vertical a {
border-bottom: 0;
}
.twNav-left {
left:auto;
}
.twNav ul {
position:absolute;
right:10px;
margin-top:auto;
}
.twNav ul li {
display:inline-block;
position: relative;
}
.twNav a {
float: left;
padding: 0 30px;
}
.twNav a:hover {
background: transparent;
color: #d48c3b;
}
.twNav ul ul {
visibility: hidden;
position: absolute;
top: 100%;
left: 0;
}
.twNav ul li:hover > ul {
visibility: visible;
}
.twNav ul ul ul {
border-top: 0 none;
}
.twNav ul ul li {
margin-bottom: -8px;
}
.twNav ul ul li:first-child > a {
border-top: 1px solid #305179;
}
.twNav ul ul li:hover > a {
background: #627b99;
color: #d48c3b;
}
.twNav ul ul a {
background: #305179;
padding: 12px 20px;
-webkit-box-shadow: 0 7px 23px -6px rgba(0, 0, 0, 0.75), 0 33px 24px -31px rgba(255, 255, 255, 0.45) inset;
-moz-box-shadow: 0 7px 23px -6px rgba(0, 0, 0, 0.75), 0 33px 24px -31px rgba(255, 255, 255, 0.45) inset;
box-shadow: 0 7px 23px -6px rgba(0, 0, 0, 0.75), 0 33px 24px -31px rgba(255, 255, 255, 0.45) inset;
-moz-border-radius: 0 0 3px 3px;
-webkit-border-radius: 0 0 3px 3px;
border-radius: 0 0 3px 3px;
}
.twNav ul ul li .nav-sep {
display:none;
}
You can add a class to the <a> tags of the dropdown menu like: "menu-item" and then set a fixed width to them, for example: 100px;
Example here.
HTML:
<li>
<div class="nav-sep"></div>
Stuff
</li>
<li>
<div class="nav-sep"></div>
StuffStuff
</li>
<li>
<div class="nav-sep"></div>
StuffStuffStuff
</li>
CSS:
.menu-item {
width:100px;
}
In this Thread i found out that what i wanted is not possible. But there was a solution that helped my. I did it with jquery.
set all nested li's to be width of widest li
Here is my Example: http://jsfiddle.net/0cny47a9/2/
This is my Script:
$(document).ready(function(){
$("#menu-header-menu > li > ul").each(function() { // Loop through all the menu items that got submenu items
var Widest=0; // We want to find the widest LI... start at zero
var ThisWidth=0; // Initiate the temporary width variable (it will hold the width as an integer)
var ParentWidth=0; // Width of Parent li
ParentWidth=parseInt($(this).css('width')); // Grab the width of the Parent LI
$($(this).children()).each(function() { // Loop through all the children LIs in order to find the widest
ThisWidth=parseInt($(this).css('width')); // Grab the width of the current LI
if (ThisWidth>Widest) { // Is this LI the widest?
Widest=ThisWidth; // We got a new widest value
if (Widest<ParentWidth) {
Widest=ParentWidth;
}
}
});
$("#menu-header-menu > li > ul > li > ul").each(function() {
$(this).children().css('width',ParentWidth);
});
Widest+='px'; // Add the unit
$(this).children().css('width',Widest);
});
});

Adjust bootstrap navbar menu height

I am developing a multiline menu in bootstrap and I have used a bootstrap css class “nav-justified” for width equality of every menu. The class “nav-justified” is working very well for equal width. But I need another option that is equal height, maintain height equality for every menu in that section. I added my problem with graphically in below:
nav.navbar {
width: 100%;
border: none;
margin: 0;
padding: 0;
background: #adadad;
border-bottom: 1px solid #8e8e8e
/*#8e8e8e*/
;
}
nav.navbar-fixed-top {
height: 150px;
position: fixed;
margin-left: 5px;
margin-right: 5px;
top: 26px;
bottom: 0;
right: 0;
left: 0;
float: none;
padding: 5px 5px 0px 5px;
background: #adadad;
/*mask-image: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, #202020 25%, #202020 75%, rgba(255, 255, 255, 0) 100%);*/
box-shadow: 0 0 25px rgba(0, 0, 0, 0.1), inset 0 0 1px rgba(255, 255, 255, 0.6);
}
nav .container-fluid {
padding-right: 0px;
padding-left: 0px;
height: 100%;
}
.navbar-header .navbar-toggle .icon-bar {
background-color: black;
}
ul.top-menu {
/*width: 100%;*/
border: none;
margin: 0px 0px 0px 0px;
padding: 0;
/*height: 44px;*/
border-bottom: 1px solid #bbbbbb;
border-radius: 6px;
background: #5c5a5a;
/* Safari 4-5, Chrome 1-9 */
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#5c5a5a), to(#3d3b3b));
/* Safari 5.1, Chrome 10+ */
background: -webkit-linear-gradient(top, #3d3b3b, #5c5a5a);
/* Firefox 3.6+ */
background: -moz-linear-gradient(top, #3d3b3b, #5c5a5a);
/* IE 10 */
background: -ms-linear-gradient(top, #3d3b3b, #5c5a5a);
/* Opera 11.10+ */
background: -o-linear-gradient(top, #3d3b3b, #5c5a5a);
vertical-align: middle;
background: #353535;
/* Old browsers */
background: -moz-linear-gradient(top, #353535 0%, #5c5a5a 50%, #303030 100%);
/* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #353535), color-stop(50%, #5c5a5a), color-stop(100%, #303030));
/* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #353535 0%, #5c5a5a 50%, #303030 100%);
/* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #353535 0%, #5c5a5a 50%, #303030 100%);
/* Opera 11.10+ */
background: -ms-linear-gradient(top, #353535 0%, #5c5a5a 50%, #303030 100%);
/* IE10+ */
background: linear-gradient(to bottom, #353535 0%, #5c5a5a 50%, #303030 100%);
/* W3C */
filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#353535', endColorstr='#303030', GradientType=0);
box-shadow: 0 0 25px rgba(0, 0, 0, 0.1), inset 0 0 1px rgba(255, 255, 255, 0.6);
}
ul.top-menu > li.active {
background: #ff0000;
/* Safari 4-5, Chrome 1-9 */
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#6f0505), to(#ff0000));
/* Safari 5.1, Chrome 10+ */
background: -webkit-linear-gradient(top, #ff0000, #6f0505);
/* Firefox 3.6+ */
background: -moz-linear-gradient(top, #ff0000, #6f0505);
/* IE 10 */
background: -ms-linear-gradient(top, #ff0000, #6f0505);
/* Opera 11.10+ */
background: -o-linear-gradient(top, #ff0000, #6f0505);
outline: none;
}
ul.top-menu > li:last-child.active {
border-top-right-radius: 6px;
border-bottom-right-radius: 6px;
}
ul.top-menu > li:first-child.active {
border-top-left-radius: 6px;
border-bottom-left-radius: 6px;
}
ul.top-menu > li:hover {
cursor: pointer;
background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.2) 25%, rgba(255, 255, 255, 0.2) 75%, rgba(255, 255, 255, 0) 100%);
box-shadow: 0 0 25px rgba(0, 0, 0, 0.1), inset 0 0 1px rgba(255, 255, 255, 0.6);
}
ul.top-menu > li:last-child:hover {
border-top-right-radius: 6px;
border-bottom-right-radius: 6px;
}
ul.top-menu > li:first-child:hover {
border-top-left-radius: 6px;
border-bottom-left-radius: 6px;
}
ul.sub-menu {
/*width: 100%;*/
border: none;
margin: 0;
padding: 0;
vertical-align: middle;
}
ul.sub-menu > ul > li {
display: block;
/*width: 100%;*/
border: none;
margin: 0;
padding: 0;
vertical-align: middle;
}
ul.sub-menu > li > ul > li > a {
text-align: left;
vertical-align: middle;
/*height: auto;*/
/*width: 100%;*/
color: #101010;
font-size: 10pt;
white-space: nowrap;
text-transform: capitalize;
text-shadow: 1px 1px 1px rgba(200, 200, 200, 0.9);
}
ul.sub-menu > li > ul > li > a:hover {
cursor: pointer;
background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.2) 25%, rgba(255, 255, 255, 0.2) 75%, rgba(255, 255, 255, 0) 100%);
box-shadow: 0 0 25px rgba(0, 0, 0, 0.1), inset 0 0 1px rgba(255, 255, 255, 0.6);
color: #000;
}
ul.dropdown-menu {
margin-top: -2px;
/*position:relative;*/
width: 100%;
margin: 0;
padding: 0;
overflow: hidden;
}
li.dropdown:hover > ul.dropdown-menu {
display: block;
}
.dropdown-submenu {
position: relative;
}
.dropdown-submenu > .dropdown-menu {
top: 0px;
left: 100%;
margin-top: -1px;
margin-left: -1px;
box-sizing: border-box;
}
.dropdown-submenu:hover > .dropdown-menu {
display: block;
}
.dropdown-submenu > a:after {
display: block;
content: " ";
float: right;
width: 0;
height: 0;
border-color: transparent;
border-left-color: #ccc;
margin-top: 5px;
margin-right: -10px;
}
.dropdown-submenu:hover > a:after {
border-left-color: #fff;
}
.dropdown-submenu.pull-left {
float: none;
}
.dropdown-submenu.pull-left > .dropdown-menu {
left: -100%;
margin-left: 10px;
-webkit-border-radius: 6px 0 6px 6px;
-moz-border-radius: 6px 0 6px 6px;
border-radius: 6px 0 6px 6px;
}
.dropdown-menu > ul > ul {
border-radius: 0px;
width: 100%;
}
.dropdown-menu > li > a {
display: block;
padding: 5px 20px;
clear: both;
font-weight: normal;
line-height: 1.42857143;
color: #101010;
font-size: 10pt;
white-space: nowrap;
text-transform: capitalize;
width: 100%;
}
.dropdown-menu > li > a:hover {
background: #ff0000;
}
.dropdown-menu > li {
/*box-shadow:0 1px 1px rgba(0, 0, 0, 0.1);*/
box-sizing: border-box;
border-bottom: 0.5px solid #d5d5d5;
border-top: 0.5px solid #f9f9f9;
border-radius: 0px;
min-width: 260px;
width: 100%;
background: #f2f2f2;
text-align: left;
}
.dropdown-menu > ul > li > a {
box-sizing: border-box;
border-radius: 0px;
width: 100%;
}
.dropdown-toggle > i {
text-align: right;
right: 10px;
position: absolute;
overflow: hidden;
line-height: 1.42857143;
}
.dropdown-menu > li.manage-bar {
background: #bbbbbb;
}
.dropdown-menu > li.manage-bar a {
color: #101010;
}
.dropdown-menu > li.report-bar {
background: #bbbbbb;
}
.dropdown-menu > li.report-bar a {
color: #101010;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet" />
<nav class="navbar navbar-fixed-top" role="navigation">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="btn btn-primary navbar-toggle collapsed" data-toggle="collapse" data-target="#menu-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<!--<a class="navbar-brand" href="#">Brand</a>-->
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="menu-navbar-collapse-1">
<ul class="nav nav-justified top-menu">
<li class="active">
HOME
</li>
<li>
GARMENTS
</li>
<li>
YARN DYEING
</li>
<li>
KNITTING
</li>
<li>
FABRIC DYEING
</li>
<li>
COMMON MODULES
</li>
<li>
GENERAL SETTING
</li>
</ul>
<ul class="nav nav-justified">
<li>
<ul class="nav nav-justified" style="border: 1px solid #f00">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">ADMIN <span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
Action
</li>
<li>
Another action
</li>
<li>
Something else here
</li>
<li>
Separated link
</li>
<li>
One more separated link
</li>
</ul>
</li>
</ul>
<ul class="nav nav-justified" style="border: 1px solid #f00">
<li>
HELP
</li>
</ul>
</li>
<li>
<ul class="nav nav-justified">
<li>
SUPPORT
</li>
</ul>
<ul class="nav nav-justified">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">CHAT <span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
Action
</li>
<li>
Another action
</li>
<li>
Something else here
</li>
<li>
Separated link
</li>
<li>
One more separated link
</li>
</ul>
</li>
</ul>
</li>
<li>
<ul class="nav nav-justified">
<li>
NO MENU
</li>
</ul>
<ul class="nav nav-justified">
<li>
NO MENU
</li>
</ul>
</li>
<li>
<ul class="nav nav-justified">
<li>
NO MENU
</li>
</ul>
<ul class="nav nav-justified">
<li>
NO MENU
</li>
</ul>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>
EDIT==================================================
I have fixed this problem in plunker
But another problem is arising bootstrap dropdown popup does not come properly in IE, Like as below
I need this solution, this is working in chrome and mozila, whats the problem of me?
The complete solution is here
HTML CODE
html {
font-size: 10px;
position: relative;
min-height: 100%;
-ms-text-size-adjust: 100%;
-webkit-text-size-adjust: 100%;
}
html, body {
overflow-x: hidden;
height: 100%;
margin: 0;
}
body {
background: #efeff0 /*url('../img/background.jpg') no-repeat*/;
background-size: cover;
background-attachment: fixed;
/*font: 300 16px 'segoe', Helvetica, Arial, sans-serif;*/
background-color: #efeff0;
color: #303030;
font-family: segoe,"Helvetica Neue",Arial,sans-serif;
font-size: 14px;
line-height: 1.42857;
height: 100%;
width: 100%;
position: absolute;
/*border:5px solid #5f5f5f;*/
overflow: hidden;
}
/* Customize the nav-justified links to be fill the entire space of the .navbar */
.navbar-header .navbar-toggle .icon-bar {
background-color: black;
}
.nav-justified > li > a {
color: inherit;
}
.nav-justified > .active > a,
.nav-justified > .active > a:hover,
.nav-justified > .active > a:focus {
background-image: none;
background: none;
-webkit-box-shadow: inset 0 3px 7px rgba(0,0,0,.15);
box-shadow: inset 0 3px 7px rgba(0,0,0,.15);
}
.nav-justified > li:first-child > a {
/*border-radius: 5px 5px 0 0;*/
}
.nav-justified > li:last-child > a {
/*border-bottom: 0;
border-radius: 0 0 5px 5px;*/
}
.nav-justified > li > a:hover {
background: none;
background-image: none;
}
.nav > li > a {
padding: 5px 10px 0px 20px;
}
#media (min-width: 768px) {
/*.nav-justified {
max-height: 52px;
}*/
.nav-justified > li > a {
border-right: 0.5px solid #404040;
border-left: 0.5px solid #353535;
color: #fff;
text-align: left;
}
.nav-justified > li:first-child > a {
border-left: 0;
border-radius: 6px 0 0 6px;
}
.nav-justified > li:last-child > a {
border-right: 0;
border-radius: 0 6px 6px 0;
}
}
.navbar-collapse {
border-top: 0px solid #4b4b4b;
/*padding:0px 5px 0px 5px;*/
}
/*.navbar-fixed-top .navbar-collapse, .navbar-static-top .navbar-collapse, .navbar-fixed-bottom .navbar-collapse {
padding: 5px 5px 0px 5px;
}*/
.container > .navbar-header, .container-fluid > .navbar-header, .container > .navbar-collapse, .container-fluid > .navbar-collapse {
margin: 0px 5px 0px 5px;
}
nav.navbar-fixed-top {
height: 150px;
position: fixed;
top: 26px;
bottom: 0;
right: 0;
left: 0;
float: none;
background: #adadad;
/*mask-image: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, #202020 25%, #202020 75%, rgba(255, 255, 255, 0) 100%);*/
box-shadow: 0 0 25px rgba(0, 0, 0, 0.1), inset 0 0 1px rgba(255, 255, 255, 0.6);
}
.navbar-fixed-top, .navbar-fixed-bottom {
position: relative;
}
nav .container-fluid {
padding-right: 0px;
padding-left: 0px;
overflow: visible;
}
nav.navbar {
/*display: block;*/
width: 100%;
border: none;
margin: 0;
padding: 0;
background: #adadad;
border-bottom: 1px solid #8e8e8e /*#8e8e8e*/;
}
ul.top-menu {
width: 100%;
border: none;
margin: 5px 0px 0px 0px;
padding: 0;
min-height: 44px;
border-bottom: 1px solid #bbbbbb;
border-radius: 6px;
background: #5c5a5a;
/* Safari 4-5, Chrome 1-9 */
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#5c5a5a), to(#3d3b3b));
/* Safari 5.1, Chrome 10+ */
background: -webkit-linear-gradient(top, #3d3b3b, #5c5a5a);
/* Firefox 3.6+ */
background: -moz-linear-gradient(top, #3d3b3b, #5c5a5a);
/* IE 10 */
background: -ms-linear-gradient(top, #3d3b3b, #5c5a5a);
/* Opera 11.10+ */
background: -o-linear-gradient(top, #3d3b3b, #5c5a5a); /*box-shadow: 2px 2px 2px rgba(0,0,0,0.40);
-moz-box-shadow: 2px 2px 2px rgba(0,0,0,0.40);
-o-box-shadow: 2px 2px 2px rgba(0,0,0,0.40);
-webkit-box-shadow: 2px 2px 2px rgba(0,0,0,0.40);
-ms-box-shadow: 2px 2px 2px rgba(0,0,0,0.40);*/
vertical-align: middle;
background: #353535; /* Old browsers */
background: -moz-linear-gradient(top, #353535 0%, #5c5a5a 50%, #303030 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #353535), color-stop(50%, #5c5a5a), color-stop(100%, #303030)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #353535 0%, #5c5a5a 50%, #303030 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #353535 0%, #5c5a5a 50%, #303030 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #353535 0%, #5c5a5a 50%, #303030 100%); /* IE10+ */
background: linear-gradient(to bottom, #353535 0%, #5c5a5a 50%, #303030 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#353535', endColorstr='#303030', GradientType=0 ); /* IE6-9 */
/*background:url(NEXTIT.CK.GS.WebClient/Content/images/admin-logo.png) #fff;*/
/*mask-image: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, #202020 25%, #202020 75%, rgba(255, 255, 255, 0) 100%);*/
box-shadow: 0 0 25px rgba(0, 0, 0, 0.1), inset 0 0 1px rgba(255, 255, 255, 0.6); /*background:white;
background:rgba(255,255,255,0.8);*/
/*filter:blur(4px);
-o-filter:blur(4px);
-ms-filter:blur(4px);
-moz-filter:blur(4px);
-webkit-filter:blur(4px);*/
}
ul.top-menu > li > a {
color: #fff;
font-weight: normal;
}
ul.top-menu > li.active {
background: #ff0000;
/* Safari 4-5, Chrome 1-9 */
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#6f0505), to(#ff0000));
/* Safari 5.1, Chrome 10+ */
background: -webkit-linear-gradient(top, #ff0000, #6f0505);
/* Firefox 3.6+ */
background: -moz-linear-gradient(top, #ff0000, #6f0505);
/* IE 10 */
background: -ms-linear-gradient(top, #ff0000, #6f0505);
/* Opera 11.10+ */
background: -o-linear-gradient(top, #ff0000, #6f0505);
outline: none;
}
ul.top-menu > li:last-child.active {
border-top-right-radius: 6px;
border-bottom-right-radius: 6px;
}
ul.top-menu > li:first-child.active {
border-top-left-radius: 6px;
border-bottom-left-radius: 6px;
}
ul.top-menu > li:hover {
/*background-color: #f00;*/
/*border-radius:6px;*/
/*background:rgba(255, 255, 255, 0.2);*/
cursor: pointer;
/*background: -moz-linear-gradient(top, rgba(0,0,0,0.2) 0%, rgba(255,255,255,0.5) 50%, rgba(0,0,0,0.2) 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(0,0,0,0.2)), color-stop(50%,rgba(255,255,255,0.2)), color-stop(100%,rgba(0,0,0,0.2)));
background: -webkit-linear-gradient(top, rgba(0,0,0,0.2) 0%,rgba(255,255,255,0.2) 50%,rgba(0,0,0,0.2) 100%);
background: -o-linear-gradient(top, rgba(0,0,0,0.2) 0%,rgba(255,255,255,0.2) 50%,rgba(0,0,0,0.2) 100%);
background: -ms-linear-gradient(top, rgba(0,0,0,0.2) 0%,rgba(255,255,255,0.2) 50%,rgba(0,0,0,0.2) 100%);
background: linear-gradient(to bottom, rgba(0,0,0,0.2) 0%,rgba(255,255,255,0.2) 50%,rgba(0,0,0,0.2) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#33000000', endColorstr='#33000000',GradientType=0 );
-webkit-box-shadow: inset 5px rgba(0,0,0,.2), 0 0 8px rgba(102, 175, 233, 0.6);
box-shadow: inset 5px rgba(0,0,0,.2), 0 0 8px rgba(102, 175, 233, 0.6);*/
background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.2) 25%, rgba(255, 255, 255, 0.2) 75%, rgba(255, 255, 255, 0) 100%);
box-shadow: 0 0 25px rgba(0, 0, 0, 0.1), inset 0 0 1px rgba(255, 255, 255, 0.6);
}
ul.top-menu > li:last-child:hover {
border-top-right-radius: 6px;
border-bottom-right-radius: 6px;
}
ul.top-menu > li:first-child:hover {
border-top-left-radius: 6px;
border-bottom-left-radius: 6px;
}
ul.sub-menu {
width: 100%;
height: 100px;
border: none;
margin: 0;
padding: 0;
vertical-align: middle;
list-style: none;
display: block; /*box-shadow: 2px 2px 2px rgba(0,0,0,0.40);
-moz-box-shadow: 2px 2px 2px rgba(0,0,0,0.40);
-o-box-shadow: 2px 2px 2px rgba(0,0,0,0.40);
-webkit-box-shadow: 2px 2px 2px rgba(0,0,0,0.40);
-ms-box-shadow: 2px 2px 2px rgba(0,0,0,0.40);*/
}
ul.sub-menu > li {
height: 100px;
border: none;
margin: 0;
padding: 0;
vertical-align: middle;
list-style: none;
}
ul.sub-menu > li > div {
height: 100%;
display: table;
table-layout: fixed;
border-collapse: collapse;
width: 100%;
}
ul.sub-menu > li > div > ul {
display: table-row;
}
ul.sub-menu > li > div > ul > li {
display: table-cell;
width: 100%;
border: none;
margin: 0;
padding: 0;
vertical-align: middle;
padding-left: 20px;
height: auto;
}
ul.sub-menu > li > div > ul > li > a {
text-align: left;
text-decoration: none;
height: 100%;
line-height: 100%;
display: table;
content: "";
clear: both;
vertical-align: middle;
width: 100%;
color: #101010;
font-size: 10pt;
white-space: nowrap;
text-transform: capitalize;
text-shadow: 1px 1px 1px rgba(200,200,200,0.9);
padding: 0px;
}
ul.sub-menu > li > div > ul > li > a > span {
line-height: 100%;
display: table-cell;
vertical-align: middle;
clear: both;
}
ul.sub-menu > li > div > ul > li > a > span i {
float: right;
margin-right: 14px;
content: "";
clear: both;
/*margin-top: -18px;
right: 10px;
text-align: right;*/
}
ul.sub-menu > li > div > ul > li > a:hover {
background: none;
}
ul.sub-menu > li > div > ul > li:hover {
cursor: pointer;
background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.2) 25%, rgba(255, 255, 255, 0.2) 75%, rgba(255, 255, 255, 0) 100%);
/*-webkit-box-shadow:0px 1px 1px rgba(0, 0, 0, 0.1);
-moz-box-shadow:0px 1px 1px rgba(0, 0, 0, 0.1);
box-shadow:0px 1px 1px rgba(0, 0, 0, 0.1);*/
box-shadow: 0 0 25px rgba(0, 0, 0, 0.1), inset 0 0 1px rgba(255, 255, 255, 0.6);
color: #000;
}
/*ul.sub-menu > li > div > ul > li.dropdown > ul.dropdown-menu {
top: 100%;
}*/
ul.dropdown-menu {
width: 100%;
margin: 0;
padding: 0;
}
li.dropdown:hover > ul.dropdown-menu {
display: block;
}
.dropdown-submenu {
position: relative;
}
.dropdown-submenu > .dropdown-menu {
top: 0px;
left: 100%;
margin-top: -2px;
margin-left: -1px;
/*-webkit-border-radius: 0 6px 6px 6px;
-moz-border-radius: 0 6px 6px;
border-radius: 0 6px 6px 6px;*/
/*box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);*/
box-sizing: border-box;
}
.dropdown-submenu > .dropToLeft {
left: auto;
right: 100%;
top: 0px;
/*position:relative;*/
}
.dropdown-submenu:hover > .dropdown-menu {
display: block;
}
.dropdown-submenu > a:after {
display: block;
content: " ";
float: right;
width: 0;
height: 0;
border-color: transparent;
border-left-color: #ccc;
margin-top: 5px;
margin-right: -10px;
}
.dropdown-submenu:hover > a:after {
border-left-color: #fff;
}
.dropdown-submenu.pull-left {
float: none;
}
.dropdown-submenu.pull-left > .dropdown-menu {
left: -100%;
margin-left: 10px;
-webkit-border-radius: 6px 0 6px 6px;
-moz-border-radius: 6px 0 6px 6px;
border-radius: 6px 0 6px 6px;
}
.dropdown-menu > ul > ul {
border-radius: 0px;
width: 100%;
}
.dropdown-menu > li > a {
display: block;
padding: 5px 20px;
clear: both;
font-weight: normal;
line-height: 1.42857143;
color: #101010;
font-size: 10pt;
white-space: nowrap;
text-transform: capitalize;
width: 100%;
}
.dropdown-menu > li > a:hover {
background: #ff0000;
}
.dropdown-menu > li:hover {
background: #ff0000;
}
.dropdown-menu > li {
/*box-shadow:0 1px 1px rgba(0, 0, 0, 0.1);*/
box-sizing: border-box;
border-bottom: 0.5px solid #d5d5d5;
border-top: 0.5px solid #f9f9f9;
border-radius: 0px;
width: 100%;
background: #f2f2f2;
text-align: left;
}
.dropdown-menu > ul > li > a {
/*box-shadow:0 1px 1px rgba(0, 0, 0, 0.1);*/
box-sizing: border-box;
/*border-bottom:1px solid rgba(0,0,0,0.40);
border-top:1px solid #ccc;*/
border-radius: 0px;
width: 100%;
}
.dropdown-toggle > i {
text-align: right;
right: 10px;
position: absolute;
overflow: hidden;
line-height: 1.42857143;
}
.dropdown-menu > li.manage-bar {
background: #bbbbbb;
}
.dropdown-menu > li.manage-bar a {
color: #101010;
}
.dropdown-menu > li.report-bar {
background: #bbbbbb;
}
.dropdown-menu > li.report-bar a {
color: #101010;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="description" content="" />
<meta name="author" content="" />
<script data-require="jquery#*" data-semver="2.1.1" src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link data-require="bootstrap#*" data-semver="3.2.0" rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.css" />
<script data-require="bootstrap#*" data-semver="3.2.0" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.js"></script>
<link rel="stylesheet" href="style.css" />
<script src="script.js"></script>
</head>
<body>
<nav class="navbar navbar-fixed-top" role="navigation">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#menu-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<!--<a class="navbar-brand" href="#">Brand</a>-->
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="menu-navbar-collapse-1">
<ul class="top-menu nav nav-justified">
<li class="active">HOME</li>
<li>GARMENTS</li>
<li>YARN DYEING</li>
<li>KNITTING</li>
<li>FABRIC DYEING</li>
<li>COMMON MODULES</li>
<li>GENERAL SETTING</li>
</ul>
<ul class="sub-menu nav nav-justified">
<li>
<div>
<ul>
<li class="dropdown"><span>ADMIN <span class="caret"></span></span>
<ul class="dropdown-menu" role="menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li>Separated link</li>
<li class="dropdown-submenu"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Manage
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li>Separated link</li>
<li>One more separated link</li>
</ul>
</li>
</ul>
</li>
</ul>
<ul>
<li><span>HELP</span></li>
</ul>
</div>
</li>
<li>
<div>
<ul>
<li><span>HELP</span></li>
</ul>
<ul>
<li class="dropdown"><span>CHAT<span class="caret"></span></span>
<ul class="dropdown-menu" role="menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li class="divider"></li>
<li>Separated link</li>
<li class="divider"></li>
<li>One more separated link</li>
</ul>
</li>
</ul>
</div>
</li>
<li>
<div>
<ul>
<li><span>NO MENU</span></li>
</ul>
<ul>
<li><span>NO MENU</span></li>
</ul>
</div>
</li>
<li>
<div>
<ul>
<li><span>NO MENU</span></li>
</ul>
<ul>
<li class="dropdown"><span>ADMIN<span class="caret"></span></span>
<ul class="dropdown-menu" role="menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li>Separated link</li>
<li class="dropdown-submenu ">Manage <span class="caret"></span>
<ul class="dropdown-menu dropToLeft" role="menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li>Separated link</li>
<li>One more separated link</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>
</body>
</html>

Display menu horizontal with vertical drop down?

I am trying to build a drop down menu, So far i found a really nice menu but it lists its items horizontal and displays its sub items horizontally as well.
I would like my items to be next to each other and then if it has a sub menu those items drop down.
Here is my Menu:
<link rel="stylesheet" type="text/css" href="../../Content/Menu.css" />
<div class="float-right">
<nav>
<ul class="menu" style="float: left;">
<li class="item1">Home
<ul style="display: block; ">
<li class="subitem1" >#Html.ActionLink("Home", "Index", "Home", new { #class = "active" })</li>
<li class="subitem2">#Html.ActionLink("Contact", "Contact", "Home")</li>
<li class="subitem3">#Html.ActionLink("About", "About", "Home")</li>
</ul>
</li>
<li class="item2">#Html.ActionLink("Login", "Login", "Home")</li>
</ul>
</nav>
</div>
Style Sheet
body {
font-size: 100%;
background:#32373d;
}
a {
text-decoration: none;
}
ul, ul ul {
margin: 0;
padding: 0;
list-style: none;
}
#wrapper {
width: 220px;
margin: 100px auto;
font-size: 0.8125em;
}
.menu {
width: 225px;
height: auto;
-webkit-box-shadow: 0px 1px 3px 0px rgba(0,0,0,.73), 0px 0px 18px 0px rgba(0,0,0,.13);
-moz-box-shadow: 0px 1px 3px 0px rgba(0,0,0,.73), 0px 0px 18px 0px rgba(0,0,0,.13);
box-shadow: 0px 1px 3px 0px rgba(0,0,0,.73), 0px 0px 18px 0px rgba(0,0,0,.13);
}
.menu > li > a {
background-color: #616975;
background-image: -webkit-gradient(linear, left top, left bottom, from(rgb(114, 122, 134)),to(rgb(80, 88, 100)));
background-image: -webkit-linear-gradient(top, rgb(114, 122, 134), rgb(80, 88, 100));
background-image: -moz-linear-gradient(top, rgb(114, 122, 134), rgb(80, 88, 100));
background-image: -o-linear-gradient(top, rgb(114, 122, 134), rgb(80, 88, 100));
background-image: -ms-linear-gradient(top, rgb(114, 122, 134), rgb(80, 88, 100));
background-image: linear-gradient(top, rgb(114, 122, 134), rgb(80, 88, 100));
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,StartColorStr='#727a86', EndColorStr='#505864');
border-bottom: 1px solid #33373d;
-webkit-box-shadow: inset 0px 1px 0px 0px #878e98;
-moz-box-shadow: inset 0px 1px 0px 0px #878e98;
box-shadow: inset 0px 1px 0px 0px #878e98;
width: 100%;
height: 2.75em;
line-height: 2.75em;
text-indent: 2.75em;
display: block;
position: relative;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-weight: 600;
color: #fff;
text-shadow: 0px 1px 0px rgba(0,0,0,.5);
}
.menu ul li a {
background: #fff;
border-bottom: 1px solid #efeff0;
width: 100%;
height: 2.75em;
line-height: 2.75em;
text-indent: 2.75em;
display: block;
position: relative;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 0.923em;
font-weight: 400;
color: #878d95;
}
.menu ul li:last-child a {
border-bottom: 1px solid #33373d;
}
.menu > li > a:hover, .menu > li > a.active {
background-color: #35afe3;
background-image: -webkit-gradient(linear, left top, left bottom, from(rgb(69, 199, 235)),to(rgb(38, 152, 219)));
background-image: -webkit-linear-gradient(top, rgb(69, 199, 235), rgb(38, 152, 219));
background-image: -moz-linear-gradient(top, rgb(69, 199, 235), rgb(38, 152, 219));
background-image: -o-linear-gradient(top, rgb(69, 199, 235), rgb(38, 152, 219));
background-image: -ms-linear-gradient(top, rgb(69, 199, 235), rgb(38, 152, 219));
background-image: linear-gradient(top, rgb(69, 199, 235), rgb(38, 152, 219));
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,StartColorStr='#45c7eb', EndColorStr='#2698db');
border-bottom: 1px solid #103c56;
-webkit-box-shadow: inset 0px 1px 0px 0px #6ad2ef;
-moz-box-shadow: inset 0px 1px 0px 0px #6ad2ef;
box-shadow: inset 0px 1px 0px 0px #6ad2ef;
}
.menu > li > a.active {
border-bottom: 1px solid #1a638f;
}
.menu > li > a:before {
content: '';
background-image: url(../images/sprite.png);
background-repeat: no-repeat;
font-size: 36px;
height: 1em;
width: 1em;
position: absolute;
left: 0;
top: 50%;
margin: -.5em 0 0 0;
}
.item1 > a:before {
background-position: 0 0;
}
.item2 > a:before {
background-position: -38px 0;
}
.item3 > a:before {
background-position: 0 -38px;
}
.item4 > a:before {
background-position: -38px -38px;
}
.item5 > a:before {
background-position: -76px 0;
}
.menu > li > a span {
font-size: 0.857em;
display: inline-block;
position: absolute;
right: 1em;
top: 50%;
background: #48515c;
line-height: 1em;
height: 1em;
padding: .4em .6em;
margin: -.8em 0 0 0;
color: #fff;
text-indent: 0;
text-align: center;
-webkit-border-radius: .769em;
-moz-border-radius: .769em;
border-radius: .769em;
-webkit-box-shadow: inset 0px 1px 3px 0px rgba(0, 0, 0, .26), 0px 1px 0px 0px rgba(255, 255, 255, .15);
-moz-box-shadow: inset 0px 1px 3px 0px rgba(0, 0, 0, .26), 0px 1px 0px 0px rgba(255, 255, 255, .15);
box-shadow: inset 0px 1px 3px 0px rgba(0, 0, 0, .26), 0px 1px 0px 0px rgba(255, 255, 255, .15);
text-shadow: 0px 1px 0px rgba(0,0,0,.5);
font-weight: 500;
}
.menu > li > a:hover span, .menu > li a.active span {
background: #2173a1;
}
.menu > li > ul li a:before{
content: '▶';
font-size: 8px;
color: #bcbcbf;
position: absolute;
width: 1em;
height: 1em;
top: 0;
left: -2.7em;
}
.menu > li > ul li:hover a,
.menu > li > ul li:hover a span,
.menu > li > ul li:hover a:before {
color: #32373D;
}
.menu ul > li > a span {
font-size: 0.857em;
display: inline-block;
position: absolute;
right: 1em;
top: 50%; /
background: #fff;
border: 1px solid #d0d0d3;
line-height: 1em;
height: 1em;
padding: .4em .7em;
margin: -.9em 0 0 0;
color: #878d95;
text-indent: 0;
text-align: center;
-webkit-border-radius: .769em;
-moz-border-radius: 769em;
border-radius: 769em;
text-shadow: 0px 0px 0px rgba(255,255,255,.01));
}
What property in my style sheet is causing my Menu to list like this?
Is there a way to override what every is causing the menu you to do this?
Edit
Html list:
<div class="float-right">
<nav>
<ul class="menu" style="float: left;">
<li class="item1">Home
<ul style="display: block; ">
<li class="subitem1" ><a class="active" href="/?Length=4">Home</a></li>
<li class="subitem2">Contact</li>
<li class="subitem3">About</li>
</ul>
</li>
<li class="item2">Login</li>
</ul>
</nav>
</div>
.menu {
width: 225px;
}
the width:225px prevents the menu from displaying correctly.
http://jsfiddle.net/wFyMs/2/
Why can you make it simplier?
Try rewrite it by this pattern:
CSS
li { float: left; }
li ul li { clear: both; }