cant see the elements of the dropdownmenü - html

I created a navigationbar. Now I want to expand this bar to dropdown menü.
Here is a jfiddle.
If I hover over last element, i cant see the dropdownbar (class="dropdown_ul")and if I use "examine element" I see that the css change the display of the dropdown_ul, but I cant see/find it.
.float_left {
float: left;
}
.float_right {
float: right;
}
.clear_both {
clear: both;
}
* {
margin: 0px;
padding: 0px;
font-family:"Oswald", sans-serif;
}
body {
background-color: #E2DCDC;
}
nav {
width: 994px;
background-color: #77BCF1;
border: 3px solid white;
margin: 45px auto;
color: black;
}
nav > .navigationbar_ul {
list-style-type: none;
width: 100%;
font-size: 0px;
}
nav > .navigationbar_header {
width: 100%;
text-align: center;
}
.navigationbar_li {
display: inline-block;
}
.navigationbar_li_left {
border-right: 3px solid white;
}
.navigationbar_li_right {
border-right: none;
border-left: 3px solid white;
}
.navigationbar_li:last-child {
margin-right: 0px;
}
.navigationbar_li > .navigationbar_a {
color: black;
font-size: 16px;
display: block;
padding: 10px 15px;
text-decoration: none;
transition: background-color 0.2s ease-in-out 0s;
}
.navigationbar_li > .navigationbar_a:hover {
background-color: white;
}
.dropdown_ul {
position: absolute;
top: 0px;
left: 0;
width: 150px;
visibility: hidden;
display: none;
}
.dropdown_li {
display: block;
}
.navigationbar_li:hover .dropdown_ul {
display: block;
opacity: 1;
visibility: visible;
}
<nav>
<ul class="navigationbar_ul">
<div class="float_left">
<li class="navigationbar_li navigationbar_li_left"><a class="navigationbar_a" href="#">Link 1</a></li>
<li class="navigationbar_li navigationbar_li_left"><a class="navigationbar_a" href="#">Link 2</a></li>
</div>
<div class="float_right">
<li class="navigationbar_li navigationbar_li_right"><a class="navigationbar_a" href="#">Link 3</a>
<ul class="dropdown_ul">
<li class="dropdown_li"><a class="dropdown_a">Link 1</a></li>
</ul>
</li>
</div>
<div class="clear_both"></div>
</ul>
</nav>

It is because you have specified font-size 0 here
nav > .navigationbar_ul {
font-size: 0px;
}
Change the 0px to i.e. 14px and you will see the text.

You got to do 3 things.
Semantically it is wrong to add div in ul right after, instead of li. So remove .float_left and .float_left divs and add this class to li itself.
Add position: relative; to .navigationbar_li_right so that absolutely positioned .dropdown_ul will display right down like a drop down menu as you have asked.
Increase the font-size when you hover .navigationbar_li_right
http://jsfiddle.net/6Lf0wpvz/4/

EDIT
Change .navigationbar_li:hover .dropdown_ul to:
.navigationbar_li:hover .dropdown_ul {
display: block !important;
opacity: 1;
visibility: visible !important;
}
You need to add !important in order to override the previous display:none and visibility:hidden
By the way, you might as well ditch the visibility:hidden when declaring display:none
Hope this helps!

Related

How to fix this dropdown navbar

I am writing a navigation bar with a dropdown option.
I have 2 problems: I can't get the dropdown to position properly under the menu, + also when I try to move the mouse to click on the elements in the dropdown submenu it closes as soon as I move.
Can anyone suggest a fix?
Thanks
On codepen:
https://codepen.io/-royqooe/pen/GRxaVbm
/* CSS section for home */
.navtop {
position: relative;
background-color: #333333;
height: 50px;
width: 100%;
border: 0;
}
.navtop div {
display: flex;
margin: 0 auto;
height: 100%;
}
.navtop div h1,
.navtop div a {
display: inline-flex;
align-items: center;
}
.navtop div h1 {
flex: 1;
font-size: 24px;
padding: 0;
margin: 0;
margin-left: 2%;
color: #f5f8ff;
font-weight: normal;
}
.navtop div a {
padding: 0 12px;
text-decoration: none;
color: #c1c4c8;
font-weight: bold;
}
.navtop div a i {
padding: 2px 8px 0 0;
}
.navtop div a:hover {
color: #66ccff;
}
/* sequel for home and navbar */
nav.navtop {
font-family: monospace;
}
.navtop>.navbar>ul {
list-style: none;
margin: 0;
padding-left: 0;
}
.navtop li {
display: block;
float: left;
padding: 0.5rem 0;
position: relative;
text-decoration: none;
transition-duration: 0.3s;
}
.navtop ul li ul {
background: red;
visibility: hidden;
opacity: 0;
min-width: 5rem;
position: absolute;
transition: all 0.5s ease;
margin-top: 1rem;
left: 0;
display: none;
}
.navtop ul li:hover>ul,
.navtop ul li ul:hover {
visibility: visible;
opacity: 1;
display: block;
}
.navtop ul li ul li {
clear: both;
width: 100%;
}
#media screen and (max-width: 760px) {
.topbar-text {
display: none;
}
}
<nav class="navlol navtop" role="navigation">
<div class="navbar">
<h1>Websitee Title</h1>
<ul>
<li><i class="fa-solid fa-file"></i><span class="topbar-text">Home</span></li>
<li>Two
<ul class="dropdownnn">
<li>Sub-1</li>
<li>Sub-2</li>
<li>Sub-3</li>
</ul>
</li>
<li class="navelements">Three</li>
<li><i class="fas fa-user-circle"></i><span class="topbar-text">Profile</span></li>
<li><i class="fas fa-sign-out-alt"></i><span class="topbar-text">Logout</span></li>
</ul>
</div>
</nav>
got an easy fix for you:
add this
.navtop li {
min-height:25px;
}
the issue is that that menu li was way shorter than the others to the sides due to the icons, even better maybe is instead adding this instead:
.navtop li {
height:100%
}
both worked for me
In the screenshot, the yellow color is the area that <li> element is covering. You can see there is a gap between <li> element and submenu. When you try to move the mouse to submenu, your cursor goes out of yellow area and the submenu hides.
The solution would be to position the submenu so it starts exactly after yellow area and make sure there is no gap. Apply margin-top of 0.5rem on submenu instead of 1rem.

How to slide line in css?

https://imgur.com/a/V2W5jTZ (If you can't see the image)
When I click on one heading the line should appear, but when I click on another heading I want the line to slide to the next heading.
I have already created the same menu navigator for each heading(page), and I just display line under the page that's open
Ex:
Heading code
<p class="content">
About Us
Position
Commerical Projects
Residential Projects
</p>
After setting all the same css, i have used hr in this way:
hr{
position: absolute;
top: 100px;
right: 168px;
width: 240px;
border-color: red;
}
p a {
font-family: sans-serif;
text-decoration: none;
color: gray;
position: relative;
margin: 10px 0;
display: inline-block;
padding: 12px 10px;
}
p a::after {
content: "";
background: blue;
height: 1px;
position: absolute;
bottom: 0;
transition: .16s all 0.025s;
}
p a::after {
left: 100%;
right: 0;
}
p a:hover ~ a::after {
left: 0;
right: 100%;
}
p a:hover::after {
left: 0;
right: 0;
}
<p class="content">
About Us
Position
Commerical Projects
Residential Projects
</p>
try this :)
I'd recommend writing a css class with the desired style which you would apply to an
you will need some java-script to apply the class to the element when clicked but here's an example to get you started
https://www.w3schools.com/howto/howto_js_active_element.asp
You can use pseudo css classes to show underline for a active element(anchor tag).
There are different states of pseudo classes like active, hover, focus etc
Most probably you can use focus class to solve your problem. (active and hover can also be used to handle different scenarios )
Here is an example to solve your problem
a {
text-decoration: none;
}
a:focus {
border-bottom: 1px solid red;
}
also instead of text-decoration: underline; you may use border-bottom: 1px solid red; which is more clear under line.
Here is full css code which may help you to better understand the solution :
/*To hide the default behaviour of <a> tag*/
a {
text-decoration: none;
}
/***By using text-decoration: underline;***/
/* a:active, a:focus, a:hover {
text-decoration: underline;
} */
/***To handle different cases***/
/* a:active, a:focus, a:hover {
border-bottom: 1px solid red;
} */
/***Final solution - to handle your requirement***/
a:focus {
border-bottom: 1px solid red;
}
You can also use the commented code by uncommenting it check different scenarios.
You can check this link for details on how to build it: https://codepen.io/arjunamgain/pen/lGALt
This should be good enough to achieve the desired functionality. Instead of the red background in the css section just use a border rule, like:
border-bottom: 4px solid #d90000;
You can use something like this
$(document).ready(function() {
var $slider = $('nav .slider'),
width = $('nav ul li').width;
$slider.width(width);
});
$(window).resize(function() {
var $slider = $('nav .slider'),
width = $('nav ul li').width,
$isActive = $('nav ul li.isactive'),
isX = $isActive.position().left,
isW = $isActive.width();
$slider.width(width);
$('nav ul li').each(function() {
var x = $(this).position().left,
w = $(this).width();
$(this).on({
mouseenter: function() {
$slider.css({
left: x,
width: w
});
},
mouseleave: function() {
$slider.css({
left: isX,
width: isW
});
}
});
});
}).resize();
*,
*:before,
*:after {
box-sizing: border-box;
}
a {
color: #ea3830;
text-decoration: none;
}
nav {
position: relative;
width: 100%;
max-width: 960px;
min-width: 400px;
height: 50px;
margin: 25px auto;
border-bottom: 3px solid #eee;
text-align:center;
}
nav .slider {
position: absolute;
bottom: 0;
width: 25%;
height: 3px;
box-shadow: 0 3px #ea3830;
transition: all 0.3s ease-in-out;
}
nav ul {
padding: 0;
height: 50px;
display: flex;
flex-flow: row nowrap;
justify-content: space-around;
align-items: center;
}
nav ul li {
width: 25%;
height: 50px;
flex: 25%;
line-height: 50px;
list-style: none;
}
nav ul li a {
padding: 0 25px;
display: block;
font-weight: 600;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<nav>
<div class='slider'></div>
<ul>
<li class='isactive'>
<a href='#'>Index</a>
</li>
<li>
<a href='#'>About</a>
</li>
<li>
<a href='#'>Work</a>
</li>
<li>
<a href='#'>Contact</a>
</li>
</ul>
</nav>
Here you go man try this :)
* {
box-sizing: border-box;
}
body {
font: 300 100% 'Helvetica Neue', Helvetica, Arial;
}
.container {
width: 50%;
margin: 0 auto;
}
ul li {
display: inline;
text-align: center;
}
a {
display: inline-block;
width: 25%;
padding: .75rem 0;
margin: 0;
text-decoration: none;
color: #333;
}
.two:hover ~ hr {
margin-left: 25%;
}
.three:hover ~ hr {
margin-left: 50%;
}
.four:hover ~ hr {
margin-left: 75%;
}
hr {
height: .25rem;
width: 25%;
margin: 0;
background: tomato;
border: none;
transition: .3s ease-in-out;
}
<div class="container">
<ul>
<li class="one">About Us</li><!--
--><li class="two">Position</li><!--
--><li class="three">Commerical Projects</li><!--
--><li class="four">Residential Projects</li>
<hr />
</ul>
</div>

Sub menu items keeps moving... How to make them fixed?

Ok, so here we go again...
The elements in my sub-menu keep moving when I hover over them. I can't seem to find anything on this issue. I've asked this question before for my nav bar but the answer I received- (Have the same padding for the a tags and put a border around them- but have it transparent) does not work with the sub-menu. I've tried to play with the padding as well with no luck.
Another thing...(I apologize for all questions, I just hate asking on here.. Some can be condescending) I had assign a class to each element (or list item) of the nav bar because when I attempted to put a border around them, each of the sub-menu elements also inherited the border as well. Is the a "cleaner" way to do it? I tried the :not() tag but I can't seem to get that to work either.
Lastly, I ask questions on this site as a last option. I am a newbie programmer/web designer who is looking to network and would like to connect with people who are more experienced before I get banned from asking a question that someone else sees as futile. If this last request is against the terms of service please let me know - I will delete it.
HTML
/* Style The Dropdown Button */
.dropbtn {
background-color: transparent;
font-family: 'Homemade Apple',cursive;
color: pink;
padding: 4px;
font-size: 16px;
cursor: pointer;
border: 3px solid pink;
border-radius: 16px;}
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #DDDDEE;
border: 3px solid pink;
border-top: hidden !important;
border-radius: 16px;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 2;
}
/* Links inside the dropdown */
.dropdown-content a {
color: #B76E79;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.dropdown-content a:hover {color: #B76E79}
/* Show the dropdown menu on hover */
.dropdown:hover .dropdown-content {
display: block;
}
/* Change the background color of the dropdown button when the dropdown
content is shown */
.dropdown:hover .dropbtn {
color: #B76E79;
background-color: #DDDDEE;
}
</style>
</head>
<body>
<h1>Debi's Babies</h1>
<h2>A Mother's collection of Snow Babies</h2>
<ul class = "nav">
<li class= "one">Home</li>
<li class= "two">Original Figurines</li>
<li class= "three">Villages</li>
<div class = "dropdown">
<a href= "guest_collect.html"<button class="dropbtn">The Guest
Collection</button></a>
<div class = "dropdown-content">
<li class="c">Dr. Seuss</li>
<li class="d">Rudolph and Friends</li>
<li class="e">Santa</li>
<li class="f">Wizard of Oz</li>
</div>
</div>
</li>
<li class= "four">Oranments</li>
<li class= "five">Snow Bunnies</li>
</ul>
</body>
</html>
CSS
/*navbar*/
.nav {
list-style-type: none;
margin: 0;
padding: 0;
text-align: center;
display: block;
position: relative;}
.nav li{
display: inline-block;
}
.nav a {
display: inline-block;
color: pink;
font-family: 'Homemade Apple', cursive;
padding: 6px;}
.nav li a:hover {
color: #B76E79;
padding: 8px;
z-index: 1;
}
.one,.two,.three,.four,.five {
border: 3px solid pink;
border-radius: 16px;}
.one:hover,.two:hover,.three:hover,.four:hover,.five:hover {
background: #DDDDEE;
}
As far as I can tell, the 'positioning' change you're talking about is coming from the additional padding on hover. This is specifically coming from the declaration:
.nav li a:hover {
padding: 8px;
}
Removing this solves the problem. However, in addition to this, your <a> tag is missing the >, and you have one </li> too many.
Both of those have also been corrected in the following example:
/* Style The Dropdown Button */
.dropbtn {
background-color: transparent;
font-family: 'Homemade Apple', cursive;
color: pink;
padding: 4px;
font-size: 16px;
cursor: pointer;
border: 3px solid pink;
border-radius: 16px;
}
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #DDDDEE;
border: 3px solid pink;
border-top: hidden !important;
border-radius: 16px;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
z-index: 2;
}
/* Links inside the dropdown */
.dropdown-content a {
color: #B76E79;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.dropdown-content a:hover {
color: #B76E79
}
/* Show the dropdown menu on hover */
.dropdown:hover .dropdown-content {
display: block;
}
/* Change the background color of the dropdown button when the dropdown
content is shown */
.dropdown:hover .dropbtn {
color: #B76E79;
background-color: #DDDDEE;
}
/*navbar*/
.nav {
list-style-type: none;
margin: 0;
padding: 0;
text-align: center;
display: block;
position: relative;
}
.nav li {
display: inline-block;
}
.nav a {
display: inline-block;
color: pink;
font-family: 'Homemade Apple', cursive;
padding: 6px;
}
.nav li a:hover {
color: #B76E79;
/*padding: 8px;*/
z-index: 1;
}
.one,
.two,
.three,
.four,
.five {
border: 3px solid pink;
border-radius: 16px;
}
.one:hover,
.two:hover,
.three:hover,
.four:hover,
.five:hover {
background: #DDDDEE;
}
<h1>Debi's Babies</h1>
<h2>A Mother's collection of Snow Babies</h2>
<ul class="nav">
<li class="one">Home</li>
<li class="two">Original Figurines</li>
<li class="three">Villages</li>
<div class="dropdown">
<a href="guest_collect.html"><button class="dropbtn">The Guest
Collection</button></a>
<div class="dropdown-content">
<li class="c">Dr. Seuss</li>
<li class="d">Rudolph and Friends</li>
<li class="e">Santa</li>
<li class="f">Wizard of Oz</li>
</div>
</div>
<li class="four">Oranments</li>
<li class="five">Snow Bunnies</li>
</ul>
As for your second question, you don't have to assign a class to each list item element. You can target the li directly. Depending on exactly which <li> elements you're trying to target, you can increase the specificity.
The problem for you is that .nav li won't work, as that will target any <li> element that is a child of .nav. In order to only target the direct children (excluding grandchildren), you need to make use the child combinator (>), with .nav > li.
Finally, I'm afraid that StackOverflow is a question-answer website, not a place to connect with other developers. If you're looking to connect to other programmers, there's no better place than StackOverflow Chat.
Hope this helps! :)
It is not correct use of div in ul, ul accepts li as children only.
See this: More
so, use li instead of div like this:
<li class = "dropdown">
<a href= "guest_collect.html">The Guest
Collection</a>
<ul class = "dropdown-content">
<li class="c">Dr. Seuss</li>
<li class="d">Rudolph and Friends</li>
<li class="e">Santa</li>
<li class="f">Wizard of Oz</li>
</ul>
</li>
And insert this css code:
li {
position: relative;
}
li:hover ul {
display: block;
padding: 0;
z-index: 999;
}
li ul {
position: absolute;
display: none;
list-style: none;
background-color: #DDDDEE;
border-radius: 5px;
top: 42px;
}
.nav li ul li {
width: 100%;
}
And other css codes:see code snippet
.nav {
list-style-type: none;
margin: 0;
padding: 0;
text-align: center;
display: block;
position: relative;
margin: 0 auto;
width: 100%;
}
.nav li{
display: inline-block;
}
.nav a {
display: block;
color: pink;
font-family: 'Homemade Apple', cursive;
padding: 6px;}
.nav li a:hover {
color: #B76E79;
padding: 8px;
z-index: 1;
}
.one,.two,.three,.four,.five,.dropdown {
border: 3px solid pink;
border-radius: 16px;}
.one:hover,.two:hover,.three:hover,.four:hover,.five:hover,.dropdown:hover {
background: #DDDDEE;
}
li {
position: relative;
}
li:hover ul {
display: block;
padding: 0;
z-index: 999;
}
li ul {
position: absolute;
display: none;
list-style: none;
background-color: #DDDDEE;
border-radius: 5px;
top: 42px;
}
.nav li ul li {
width: 100%;
}
<h1>Debi's Babies</h1>
<h2>A Mother's collection of Snow Babies</h2>
<ul class = "nav">
<li class= "one">Home</li>
<li class= "two">Original Figurines</li>
<li class= "three">Villages</li>
<li class = "dropdown">
<a href= "guest_collect.html">The Guest
Collection</a>
<ul class = "dropdown-content">
<li class="c">Dr. Seuss</li>
<li class="d">Rudolph and Friends</li>
<li class="e">Santa</li>
<li class="f">Wizard of Oz</li>
</ul>
</li>
</div>
</li>
<li class= "four">Oranments</li>
<li class= "five">Snow Bunnies</li>
</ul>

Change css of list item before an after the item that is being hovered over

I've created navigation menu for my website. Here's the html: (you can also view the sidebar menu at belairfinishing.com, its the menu on the left.)
<div><img src="../public/images/skystatic.jpg" id="LinkForBannerImage"></div>
<ul>
<li>Proccess Technology</li>
<li>Equipment</li>
<li>Media & Compounds</li>
<li>Parts Cleaners & Dryers</li>
<li>Waste Water Treatment</li>
<li>Precious Metal Recovery</li>
<li>Consulting</li>
<li>Technical Articles</li>
<li>Press Releases</li>
<li>Toolhoning.com</li>
<li>Distributor Log In </li>
</ul>
</div>
Basically what I would like to happen is that when you hover over one of the items, ONLY the items directly before an after that get a red border. So if someone were to hover over Consulting, then Technical Articles and Precious Metal Recovery will have red borders.
I've been looking this up all morning and haven't found anything that works. So far I've tried to use nth-child(-n) and nth-child(n) to get 1 above an 1 below but I can't get that to actually work. Am I messing up the syntax or is their a better solution for this problem?
Thanks for the help!
Using CSS you could only select the next element using the adjacent sibling selector(+), however CSS doesn't have a previous sibling selector.
This could be achieve using jQuery.
$('li').hover(
function() {
$(this).next().find('a').addClass('highlight');
$(this).prev().find('a').addClass('highlight');
},
function() {
$(this).next().find('a').removeClass('highlight');
$(this).prev().find('a').removeClass('highlight')
})
#cssmenu {
text-align: center;
}
ul {
padding: 0;
list-style: none;
white-space: nowrap;
}
li {
display: inline-block;
vertical-align: top;
}
a {
display: block;
text-decoration: none;
width: 130px;
height: 50px;
line-height: 50px;
color: white;
background: #222;
box-sizing: border-box;
}
a:hover {
color: rosybrown;
}
.highlight {
border-bottom: 4px solid rosybrown;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="cssmenu">
<ul>
<li class="active">Home</li
><li>About Us</li
><li>Contact Us</li
><li>Trade Shows</li
><li>Vibratory Workshops</li
><li class="last">Directions</li>
</ul>
</div>
Edit
You could also make it work using CSS alone.
The idea is to add a :before :pseudo-element to a on :hover, if the a is not a descendant of first li and :after :pseudo-element, if the a is not a descendant of the last li.
i.e, li:not(:first-child) a:hover:before, li:not(:last-child) a:hover:after.
In simple words, it won't add the line on the left if the li is the first element and won't add the line on the right if the li is the last element.
body {
margin: 0;
}
#cssmenu {
text-align: center;
margin: 0;
}
ul {
padding: 0;
margin: 0;
list-style: none;
white-space: nowrap;
}
li {
display: inline-block;
vertical-align: top;
}
a {
position: relative;
display: block;
text-decoration: none;
width: 130px;
height: 50px;
line-height: 50px;
color: white;
background: #222;
box-sizing: border-box;
}
a:hover {
color: rosybrown;
}
li:not(:first-child) a:hover:before, li:not(:last-child) a:hover:after {
content: '';
position: absolute;
width: 100%;
height: 4px;
left: -100%;
bottom: 0;
border-bottom: 4px solid rosybrown;
box-sizing: border-box;
}
li:not(:last-child) a:hover:after {
left: 100%;
z-index: 1;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="cssmenu">
<ul>
<li class="active">Home</li
><li>About Us</li
><li>Contact Us</li
><li>Trade Shows</li
><li>Vibratory Workshops</li
><li class="last">Directions</li>
</ul>
</div>

Cannot properly centre nav bar (uses col-md-3) bootstrap css and html

so basically I've got this code: HTML and CSS below, using bootstrap as well, and for some reason, it's not centred. It used to be, but at some point it wasn't anymore, now it pulls to the left. See image below. Any ideas?
<div class="row" id="nav-bar">
<div class="col-md-9">
<ul>
<li class="col-md-3 nav-btn" id="home">Home</li>
<li class="col-md-3 nav-btn" id="about">About</li>
<li class="col-md-3 nav-btn dropdown-toggle" id="games">
Games & Apps ▼
<div class="dropdown">
<ul>
<li>Games & Apps ▼</li>
<li id="first">Space Rodeo</li>
<li id="spaced">Boodya's Carpet Ride</li>
<li id="spaced">Ultimate Points Counter</li>
</ul>
</div>
</li>
<li class="col-md-3 nav-btn" id="blog">Blog</li>
</ul>
</div>
</div>
#nav-bar {
margin: 0px 0px 10px 0px;
height: 60px;
}
#nav-bar ul {
margin-top: 20px;
}
.col-md-3 a {
padding: 15px 40px 15px 40px;
font-size: 20px;
text-decoration: none;
text-align: center;
color: #B6B6B6;
}
#nav-bar a:hover {
color: #428bca;
}
.col-md-3 {
display: inline;
}
.col-md-9 {
float: none;
margin: auto;
left: 0;
right: 0;
}
.dropdown {
padding: 0;
margin-top: -48px;
position: absolute;
z-index: 10;
background-color: #ffffff;
box-shadow: -5px -5px 20px;
border-radius: 5px;
height: 210px;
width: 275px;
}
.dropdown ul {
padding: 0;
margin-top: 0;
}
.dropdown li {
list-style: none;
padding: 0;
width: 310px;
}
#games2 {
color: #428bca;
}
#spaced {
margin-top: 10px;
}
#first {
padding-top: 20px;
border-top: 1px solid black;
margin-top: 22px;
}
Showing result of code, the navbar is off centre
http://i.stack.imgur.com/smtTP.png
Your list items are display: inline which means they'll follow the alignment rules of text. Since you set no text-align, it defaults to the left. You can fix that by adding text-align: center to your ul so the contents will be centered.
Now the insides of the dropdown will also inherit that, you can reset that by setting text-align: left back on the dropdown ul again.
Also reset the left padding that ul has by default.
#nav-bar ul {
padding-left: 0;
text-align: center;
}
#nav-bar .dropdown ul {
text-align: left;
}
Works in this jsFiddle