Css Drop Line Menu Bar Issues - html

I've created a Menubar based on this Tutorial for my webpage.
I'd need some help at setting the right CSS Parameters, since I am not used to them anymore.
I was able to reconstruct the tutorial on a Dummy Dummy Projekt. But it isn't working for my Dummy Project.
There shouldn't be a gap between the Menu points. The drop line isn't working, it should only show the submenus, when I hover or click the menu point.
Can anyone give me a hint, how to fix this up?
JSFIDDLE
CSS code:
#header-wrapper {
background-color: #007294;
background-image: -moz-linear-gradient(top, #008dab, #007294);
background-image: -webkit-linear-gradient(top, #008dab, #007294);
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#008dab), to(#007294));
background-image: -ms-linear-gradient(top, #008dab, #007294);
background-image: -o-linear-gradient(top, #008dab, #007294);
background-image: linear-gradient(top, #008dab, #007294);
}
#header {
position: relative;
margin: 2.5% 0 2.5% 0;
padding: 0 40px 0 40px;
border-radius: 10px;
border: solid 1px #006e8b;
box-shadow: inset 0px 0px 0px 1px #12a0bf, 0px 1px 4px 0px rgba(0,0,0,0.10);
background-color: #007b9d;
background-image: -moz-linear-gradient(top, #008ead, #007b9d);
background-image: -webkit-linear-gradient(top, #008ead, #007b9d);
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#008ead), to(#007b9d));
background-image: -ms-linear-gradient(top, #008ead, #007b9d);
background-image: -o-linear-gradient(top, #008ead, #007b9d);
background-image: linear-gradient(top, #008ead, #007b9d);
height: 86px;
}
#header h1 {
position: absolute;
left: 40px;
top: 0;
color: #fff;
font-size: 2.4em;
letter-spacing: -2px;
line-height: 86px;
}
#header h1 a {
color: #fff;
text-decoration: none;
}
#header nav li {
float: left;
text-align: center;
list-style-type: none
}
#header nav {
position: absolute;
right: 40px;
top: 1px;
line-height: 84px;
text-transform: lowercase;
font-size: 1.3em;
letter-spacing: -1px;
}
#header nav a {
color: #000;
padding: 0 25px 0 25px;
outline: 0;
text-decoration: none;
}
#header nav a.current-page-item {
background-color: #007897;
background-image: -moz-linear-gradient(top, #007b99, #007897);
background-image: -webkit-linear-gradient(top, #007b99, #007897);
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#007b99), to(#007897));
background-image: -ms-linear-gradient(top, #007b99, #007897);
background-image: -o-linear-gradient(top, #007b99, #007897);
background-image: linear-gradient(top, #007b99, #007897);
box-shadow: inset 0px 1px 5px 1px rgba(0,0,0,0.1), 0px 0px 5px 1px rgba(255,255,255,0.1);
}
#header nav a:hover {
background-color: #0882a1;
background-image: -moz-linear-gradient(top, #0782a0, #077d9b);
background-image: -webkit-linear-gradient(top, #0782a0, #077d9b);
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#0782a0), to(#077d9b));
background-image: -ms-linear-gradient(top, #0782a0, #077d9b);
background-image: -o-linear-gradient(top, #0782a0, #077d9b);
background-image: linear-gradient(top, #0782a0, #077d9b);
box-shadow: inset 0px 1px 5px 1px rgba(0,0,0,0.05), 0px 0px 5px 1px rgba(255,255,255,0.05);
}
#nav test current ul {
left: 0;
}
#nav test ul {
position: absolute;
left: -999em;
width: 408px;
list-style: none;
padding: .9em 0 0;
list-style-type: none;
}
#nav test ul li {
width: auto;
margin: 0 15px 0 0;
}
#nav test ul a {
font-size: 80%;
height: auto;
padding: 0 8px;
}
#nav test li:active ul, #nav test li:hover ul {
left: 0;
position: static;
background: #fff;
}
HTML code:
<div class="container">
<div class="row">
<div class="12u">
<header id="header">
<h1>Dummy</h1>
<nav id ="nav">
<ul id="test">
<li class="current">Link1
<ul>
<li>Sub1</li>
<li>Sub1</li>
<li>Sub1</li>
</ul>
</li>
<li>Link2
<ul>
<li>Sub2</li>
<li>Sub2</li>
<li>Sub2</li>
</ul>
</li>
<li>Link3
<ul>
<li>Sub3</li>
<li>Sub3</li>
<li>Sub3</li>
</ul>
</li>
</ul>
</nav>
</header>
</div>
</div>
</div>

Like this
DEMO
CSS
* {
margin:0;
padding:0;
}
body {
font-family:"Times New Roman", Times, serif;
font-size:100%;
}
#header-wrapper {
background-color: #007294;
background-image: -moz-linear-gradient(top, #008dab, #007294);
background-image: -webkit-linear-gradient(top, #008dab, #007294);
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#008dab), to(#007294));
background-image: -ms-linear-gradient(top, #008dab, #007294);
background-image: -o-linear-gradient(top, #008dab, #007294);
background-image: linear-gradient(top, #008dab, #007294);
}
#header {
position: relative;
margin: 2.5% 0 2.5% 0;
padding: 0 40px 0 40px;
border-radius: 10px;
border: solid 1px #006e8b;
box-shadow: inset 0px 0px 0px 1px #12a0bf, 0px 1px 4px 0px rgba(0,0,0,0.10);
background-color: #007b9d;
background-image: -moz-linear-gradient(top, #008ead, #007b9d);
background-image: -webkit-linear-gradient(top, #008ead, #007b9d);
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#008ead), to(#007b9d));
background-image: -ms-linear-gradient(top, #008ead, #007b9d);
background-image: -o-linear-gradient(top, #008ead, #007b9d);
background-image: linear-gradient(top, #008ead, #007b9d);
height: 86px;
}
#header h1 {
position: absolute;
left: 40px;
top: 0;
color: #fff;
font-size: 2.4em;
letter-spacing: -2px;
line-height: 86px;
}
#header h1 a {
color: #fff;
text-decoration: none;
}
#nav {
list-style:none;
font-weight:bold;
height:4.1em;
margin:75px auto 0;
width:816px;
position:relative;
line-height:1.4em;
}
#nav li {
width:136px;
float:left;
text-align:center;
}
#nav a {
height:1.5em;
display:block;
text-decoration:none;
color:#000;
outline:0;
}
#nav a.last {
border-right-width:1px;
}
#nav a:active, #nav a:focus, #nav a:hover {
color:#000;
}
#nav li.current a {
}
/* --------- Sub Nav --------- */
#nav li.current ul a {
}
#nav li.current ul {
left:0;
}
#nav ul {
position:absolute;
left:-999em;
width:816px;
list-style:none;
padding:.9em 0 0;
}
#nav ul li {
width:auto;
margin:0 15px 0 0;
}
#nav ul a {
font-size:80%;
height:auto;
padding:0 8px;
color:#999;
}
#nav ul a:active, #nav ul a:focus, #nav ul a:hover {
color:#000;
border-color:#000;
}
#nav li:active ul, #nav li:hover ul {
left:0;
background:#fff;
}
#nav ul li.subcurrent a {
color:#000;
border-color:#000;
}

Related

List item header change background color onClick

How to change header list items color onClick?By default home item background color is green.When I click contact item or any other it should get background color green and home item shouldn't have green background anymore!
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="art-main">
<header class="art-header">
<nav class="art-nav">
<ul class="art-hmenu">
<li>Home</li>
<li>Contact Us</li>
<li>About</li>
</ul>
</nav>
</header>
</div>
</body>
</html>
.art-header
{
margin:0 auto;
height: 100px;
background-position: 19px 6px, 0 0;
position: relative;
width: 900px;
z-index: auto !important;
}
.art-nav
{
padding:5px 2px;
position: absolute;
margin: 0;
top: 20px;
width: 100%;
z-index: 100;
text-align: right;
}
ul.art-hmenu li
{
position: relative;
z-index: 5;
display: block;
float: left;
background: none;
margin: 0;
padding: 0;
border: 0;
}
ul.art-hmenu
{
display: inline-block;
vertical-align: middle;
}
ul.art-hmenu>li {
margin-left: 2px;
}
ul.art-hmenu>li:first-child {
margin-left: 1px;
}
ul.art-hmenu>li:last-child, ul.art-hmenu>li.last-child {
margin-right: 1px;
}
ul.art-hmenu>li>a
{
-webkit-border-radius:5px;
-moz-border-radius:5px;
border-radius:5px;
border:1px solid transparent;
padding:0 22px;
margin:0 auto;
position: relative;
display: block;
height: 51px;
cursor: pointer;
text-decoration: none;
color: #808080;
line-height: 51px;
text-align: center;
}
.art-hmenu>li>a,
.art-hmenu>li>a:link,
.art-hmenu>li>a:visited,
.art-hmenu>li>a.active,
.art-hmenu>li>a:hover
{
font-size: 14px;
font-family: Arial, 'Arial Unicode MS', Helvetica, Sans-Serif;
font-weight: bold;
font-style: normal;
text-decoration: none;
text-transform: uppercase;
text-align: left;
}
ul.art-hmenu>li>a.active
{
background: #73B078;
background: -webkit-linear-gradient(top, #93C297 0, #5CA362 85%, #56995C 100%) no-repeat;
background: -moz-linear-gradient(top, #93C297 0, #5CA362 85%, #56995C 100%) no-repeat;
background: -o-linear-gradient(top, #93C297 0, #5CA362 85%, #56995C 100%) no-repeat;
background: -ms-linear-gradient(top, #93C297 0, #5CA362 85%, #56995C 100%) no-repeat;
-svg-background: linear-gradient(top, #93C297 0, #5CA362 85%, #56995C 100%) no-repeat;
background: linear-gradient(to bottom, #93C297 0, #5CA362 85%, #56995C 100%) no-repeat;
-webkit-border-radius:5px;
-moz-border-radius:5px;
border-radius:5px;
border:1px solid #57995C;
padding:0 22px;
margin:0 auto;
color: #FFFFFF;
text-decoration: none;
}
ul.art-hmenu>li>a:hover, .desktop ul.art-hmenu>li:hover>a
{
background: #ADAF88;
background: -webkit-linear-gradient(top, #C2C3A7 0, #969867 100%) no-repeat;
background: -moz-linear-gradient(top, #C2C3A7 0, #969867 100%) no-repeat;
background: -o-linear-gradient(top, #C2C3A7 0, #969867 100%) no-repeat;
background: -ms-linear-gradient(top, #C2C3A7 0, #969867 100%) no-repeat;
-svg-background: linear-gradient(top, #C2C3A7 0, #969867 100%) no-repeat;
background: linear-gradient(to bottom, #C2C3A7 0, #969867 100%) no-repeat;
-webkit-border-radius:5px;
-moz-border-radius:5px;
border-radius:5px;
border:1px solid #ADAF88;
padding:0 22px;
margin:0 auto;
}
ul.art-hmenu>li>a:hover,
.desktop ul.art-hmenu>li:hover>a {
color: #FFFFFF;
text-decoration: none;
}
With jquery
$('ul li a').click(function(){
if ($('ul li a').hasClass("active")){
$('ul li a').removeClass("active");
}
$(this).addClass("active");
});
.art-header
{
margin:0 auto;
height: 100px;
background-position: 19px 6px, 0 0;
position: relative;
width: 100%;
z-index: auto !important;
}
.art-nav
{
padding:5px 2px;
position: absolute;
margin: 0;
top: 20px;
width: 100%;
z-index: 100;
text-align: right;
}
ul.art-hmenu li
{
position: relative;
z-index: 5;
display: block;
float: left;
background: none;
margin: 0;
padding: 0;
border: 0;
}
ul.art-hmenu
{
display: inline-block;
vertical-align: middle;
}
ul.art-hmenu>li {
margin-left: 2px;
}
ul.art-hmenu>li:first-child {
margin-left: 1px;
}
ul.art-hmenu>li:last-child, ul.art-hmenu>li.last-child {
margin-right: 1px;
}
ul.art-hmenu>li>a
{
-webkit-border-radius:5px;
-moz-border-radius:5px;
border-radius:5px;
border:1px solid transparent;
padding:0 22px;
margin:0 auto;
position: relative;
display: block;
height: 51px;
cursor: pointer;
text-decoration: none;
color: #808080;
line-height: 51px;
text-align: center;
}
.art-hmenu>li>a,
.art-hmenu>li>a:link,
.art-hmenu>li>a:visited,
.art-hmenu>li>a.active,
.art-hmenu>li>a:hover
{
font-size: 14px;
font-family: Arial, 'Arial Unicode MS', Helvetica, Sans-Serif;
font-weight: bold;
font-style: normal;
text-decoration: none;
text-transform: uppercase;
text-align: left;
}
ul.art-hmenu>li>a.active
{
background: #73B078;
background: -webkit-linear-gradient(top, #93C297 0, #5CA362 85%, #56995C 100%) no-repeat;
background: -moz-linear-gradient(top, #93C297 0, #5CA362 85%, #56995C 100%) no-repeat;
background: -o-linear-gradient(top, #93C297 0, #5CA362 85%, #56995C 100%) no-repeat;
background: -ms-linear-gradient(top, #93C297 0, #5CA362 85%, #56995C 100%) no-repeat;
-svg-background: linear-gradient(top, #93C297 0, #5CA362 85%, #56995C 100%) no-repeat;
background: linear-gradient(to bottom, #93C297 0, #5CA362 85%, #56995C 100%) no-repeat;
-webkit-border-radius:5px;
-moz-border-radius:5px;
border-radius:5px;
border:1px solid #57995C;
padding:0 22px;
margin:0 auto;
color: #FFFFFF;
text-decoration: none;
}
ul.art-hmenu>li>a:hover, .desktop ul.art-hmenu>li:hover>a
{
background: #ADAF88;
background: -webkit-linear-gradient(top, #C2C3A7 0, #969867 100%) no-repeat;
background: -moz-linear-gradient(top, #C2C3A7 0, #969867 100%) no-repeat;
background: -o-linear-gradient(top, #C2C3A7 0, #969867 100%) no-repeat;
background: -ms-linear-gradient(top, #C2C3A7 0, #969867 100%) no-repeat;
-svg-background: linear-gradient(top, #C2C3A7 0, #969867 100%) no-repeat;
background: linear-gradient(to bottom, #C2C3A7 0, #969867 100%) no-repeat;
-webkit-border-radius:5px;
-moz-border-radius:5px;
border-radius:5px;
border:1px solid #ADAF88;
padding:0 22px;
margin:0 auto;
}
ul.art-hmenu>li>a:hover,
.desktop ul.art-hmenu>li:hover>a {
color: #FFFFFF;
text-decoration: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="art-main">
<header class="art-header">
<nav class="art-nav">
<ul class="art-hmenu">
<li><a class="active">Home</a></li>
<li><a>Contact Us</a></li>
<li><a>About</a></li>
</ul>
</nav>
</header>
</div>

How do I center a CSS based Drop Down Menu?

I am attempting to center a drop down list, extending the grey rectangle across the screen while keeping the text in the direct center of the screen. There should only be three items at this time. These items are Home, Assignments and Projects.
Here's the html
<HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<link type="text/css" rel="stylesheet" href="http://jamcgraw.iweb.bsu.edu/assignments/stylesheet.css" />
<title>McGraw</title>
</head>
<div align="center">
<body>
<li>Home
</li>
<li>Assignments
<ul>
<li>
</li>
</ul>
</li>
<li>Projects
<ul>
<li><a href="http://jamcgraw.iweb.bsu.edu/projects/project1/project1.zip" target="_blank">
Project 1</a>
</li>
</ul>
</li>
</ul>
<br />
<br />
<h2>Some of my favorite websites include:<ul>
Facebook </br>
Reddit </br>
Twitch.tv </br>
Youtube </br>
Noxxic
</ul>
</h2>
</body>
</html>
and the .css for the DDM
/*Begin Theme Style Code*/
/*Begin Regular Code*/
* {
margin: 0px;
}
/*End Regular Code*/
/*Begin Menu code*/
#menu-container ul,
#menu-container li,
#menu-container span,
#menu-container a {
margin: 0;
padding: 0;
position: relative;
}
#menu-container {
/* EDITED : ADD THE FOLLOWING LINE */
text-align:center;
height: 49px;
border-radius: 0px 0px 0 0;
-moz-border-radius: 0px 0px 0 0;
-webkit-border-radius: 0px 0px 0 0;
background: #141414;
background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAxCAIAAACUDVRzAAAAA3NCSVQICAjb4U/gAAAALElEQVQImWMwMrJi+v//PxMDw3+m//8ZoPR/qBgDEhuXGLoeYswhXg8R5gAAdVpfoJ3dB5oAAAAASUVORK5CYII=) 100% 100%;
background: -moz-linear-gradient(top, #32323a 0%, #141414 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #32323a), color-stop(100%, #141414));
background: -webkit-linear-gradient(top, #32323a 0%, #141414 100%);
background: -o-linear-gradient(top, #32323a 0%, #141414 100%);
background: -ms-linear-gradient(top, #32323a 0%, #141414 100%);
background: linear-gradient(to bottom, #32323a 0%, #141414 100%);
border-bottom: 2px solid #0fa1e0;
}
#menu-container:after,
#menu-container ul:after {
content: '';
display: block;
clear: both;
}
#menu-container a {
background: #141414;
background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAxCAIAAACUDVRzAAAAA3NCSVQICAjb4U/gAAAALElEQVQImWMwMrJi+v//PxMDw3+m//8ZoPR/qBgDEhuXGLoeYswhXg8R5gAAdVpfoJ3dB5oAAAAASUVORK5CYII=) 100% 100%;
background: -moz-linear-gradient(top, #32323a 0%, #141414 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #32323a), color-stop(100%, #141414));
background: -webkit-linear-gradient(top, #32323a 0%, #141414 100%);
background: -o-linear-gradient(top, #32323a 0%, #141414 100%);
background: -ms-linear-gradient(top, #32323a 0%, #141414 100%);
background: linear-gradient(to bottom, #32323a 0%, #141414 100%);
color: #ffffff;
display: inline-block;
font-family: Helvetica, Arial, Verdana, sans-serif;
font-size: 12px;
line-height: 49px;
padding: 0 20px;
text-decoration: none;
}
#menu-container ul {
list-style: none;
}
#menu-container > ul {
}
#menu-container > ul > li {
/*EDITED : CHANGE THE FOLLOWING LINE*/
float: left;
}
#menu-container > ul > li:hover:after {
content: '';
display: block;
width: 0;
height: 0;
position: absolute;
left: 50%;
bottom: 0;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
border-bottom: 10px solid #0fa1e0;
margin-left: -10px;
}
#menu-container > ul > li:first-child > a {
border-radius: 0px 0 0 0;
-moz-border-radius: 0px 0 0 0;
-webkit-border-radius: 0px 0 0 0;
}
#menu-container > ul > li:last-child > a {
border-radius: 0 0px 0 0;
-moz-border-radius: 0 0px 0 0;
-webkit-border-radius: 0 0px 0 0;
}
#menu-container > ul > li.active > a {
box-shadow: inset 0 0 3px #000000;
-moz-box-shadow: inset 0 0 3px #000000;
-webkit-box-shadow: inset 0 0 3px #000000;
background: #070707; background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAxCAIAAACUDVRzAAAAA3NCSVQICAjb4U/gAAAALklEQVQImWNQU9Nh+v//PxMDw3+m//8ZkNj/mRgYIHxy5f//Z0BSi18e2TwS5QG4MGB54HL+mAAAAABJRU5ErkJggg==) 100% 100%;
background: -moz-linear-gradient(top, #26262c 0%, #070707 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #26262c), color-stop(100%, #070707));
background: -webkit-linear-gradient(top, #26262c 0%, #070707 100%);
background: -o-linear-gradient(top, #26262c 0%, #070707 100%);
background: -ms-linear-gradient(top, #26262c 0%, #070707 100%);
background: linear-gradient(to bottom, #26262c 0%, #070707 100%);
}
#menu-container > ul > li:hover > a {
background: #070707;
background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAxCAIAAACUDVRzAAAAA3NCSVQICAjb4U/gAAAALklEQVQImWNQU9Nh+v//PxMDw3+m//8ZkNj/mRgYIHxy5f//Z0BSi18e2TwS5QG4MGB54HL+mAAAAABJRU5ErkJggg==) 100% 100%;
background: -moz-linear-gradient(top, #26262c 0%, #070707 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #26262c), color-stop(100%, #070707));
background: -webkit-linear-gradient(top, #26262c 0%, #070707 100%);
background: -o-linear-gradient(top, #26262c 0%, #070707 100%);
background: -ms-linear-gradient(top, #26262c 0%, #070707 100%);
background: linear-gradient(to bottom, #26262c 0%, #070707 100%);
box-shadow: inset 0 0 3px #000000;
-moz-box-shadow: inset 0 0 3px #000000;
-webkit-box-shadow: inset 0 0 3px #000000;
}
#menu-container .has-sub {
z-index: 1;
}
#menu-container .has-sub:hover > ul {
display: block;
}
#menu-container .has-sub ul {
display: none;
position: absolute;
width: 200px;
top: 100%;
left: 0;
}
#menu-container .has-sub ul li {
*margin-bottom: -1px;
}
#menu-container .has-sub ul li a {
background: #0fa1e0;
border-bottom: 1px dotted #6fc7ec;
filter: none;
font-size: 11px;
display: block;
line-height: 120%;
padding: 10px;
}
#menu-container .has-sub ul li:hover a {
background: #0c7fb0;
}
#menu-container .has-sub .has-sub:hover > ul {
display: block;
}
#menu-container .has-sub .has-sub ul {
display: none;
position: absolute;
left: 100%;
top: 0;
}
#menu-container .has-sub .has-sub ul li a {
background: #0c7fb0;
border-bottom: 1px dotted #6db2d0;
}
#menu-container .has-sub .has-sub ul li a:hover {
background: #095c80;
}
#menu-container {
-moz-box-shadow: 0 0 10px #888;
-webkit-box-shadow: 0 0 10px #888;
box-shadow: 0 0 10px #888;
}
/*End Menu Code*/
/*Begin Button Code*/
button.button {
border: 0 none;
font-size: 16px;
font-weight: 600;
height: 34px;
line-height: 22px;
margin-bottom: 5px;
margin-left: 0;
margin-right: 1px;
padding: 4px 11px 10px;
color: #FFFFFF;
background-color: #00CCFF;
font-family: Segoe UI, Tahoma, Helvetica, sans-serif;
}
button.button:hover {
background-color:#24459A
}
/*End Button Code*/
/*Begin Table Logo Code*/
table.header {
width: 100%;
border-collapse: collapse;
border: none;
}
table.header td {
vertical-align: top;
border: 1px solid #BFBFBF;
padding: -1px;
}
table.header td.center {
width: 800px;
height: 600px;
}
img.logo {
display: block;
margin-left: auto;
margin-right: auto;
}
/*End Table Logo Code*/
/*End Theme Style Code*/
JSFiddle
I mostly fixed your code as it was a mess.
The solution I used to center the list was:
display: table;
That should fix your problems.

Nav bar won't render correctly

My Navigation bar seems to extend out further than where the rest of my page stops. See my code within a JSfiddle with what's happening here. I can't seem to figure out why this is happening.
HTML:
<div id="header-wrapper">
<center>
<img src="images/logo.png" alt=""/>
</center>
<div class="container">
<div class="row">
<div class="12u">
<header id="header">
<nav id="nav">
<i class="fa fa-home"></i>&nbsp Home
<i class="fa fa-flag-o"></i>&nbsp RFP Recap '14-'15
<i class="fa fa-database"></i>&nbsp Archived Updates
<i class="fa fa-phone"></i>&nbsp Contact Us
<i class="fa fa-folder-open-o"></i>&nbsp Member Contacts
<i class="fa fa-sign-in"></i>&nbsp Log In
</nav>
</header>
</div>
</div>
</div>
</div>
CSS:
/* Header */
#header-wrapper {
background-color: #007294;
background-image: -moz-linear-gradient(top, #008dab, #007294);
background-image: -webkit-linear-gradient(top, #008dab, #007294);
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#008dab), to(#007294));
background-image: -ms-linear-gradient(top, #008dab, #007294);
background-image: -o-linear-gradient(top, #008dab, #007294);
background-image: linear-gradient(top, #008dab, #007294);
}
#header {
position: relative;
border-radius: 10px;
border: solid 1px #006e8b;
box-shadow: inset 0px 0px 0px 1px #12a0bf, 0px 1px 4px 0px rgba(0,0,0,0.10);
background-color: #007b9d;
background-image: -moz-linear-gradient(top, #008ead, #007b9d);
background-image: -webkit-linear-gradient(top, #008ead, #007b9d);
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#008ead), to(#007b9d));
background-image: -ms-linear-gradient(top, #008ead, #007b9d);
background-image: -o-linear-gradient(top, #008ead, #007b9d);
background-image: linear-gradient(top, #008ead, #007b9d);
height: 86px;
width: 1200px;
margin-top: 0%;
margin-right: 0;
margin-bottom: 2.5%;
margin-left: 0;
padding-top: 0;
padding-right: 0px;
padding-bottom: 0;
padding-left: 0px;
}
#header h1 {
position: absolute;
left: 0px;
top: 10px;
color: #fff;
font-size: 2.4em;
letter-spacing: -2px;
line-height: 86px;
}
#header h1 a {
color: #fff;
text-decoration: none;
}
#header nav {
position: absolute;
right: 40px;
top: 1px;
line-height: 84px;
text-transform: ;
font-size: 1.3em;
letter-spacing: -1px;
width: 1066px;
height: 92px;
}
#header nav a {
display: inline-block;
text-decoration: none;
color: #fff;
padding: 0 25px 0 25px;
outline: 0;
}
#header nav a.current-page-item {
background-color: #007897;
background-image: -moz-linear-gradient(top, #007b99, #007897);
background-image: -webkit-linear-gradient(top, #007b99, #007897);
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#007b99), to(#007897));
background-image: -ms-linear-gradient(top, #007b99, #007897);
background-image: -o-linear-gradient(top, #007b99, #007897);
background-image: linear-gradient(top, #007b99, #007897);
box-shadow: inset 0px 1px 5px 1px rgba(0,0,0,0.1), 0px 0px 5px 1px rgba(255,255,255,0.1);
}
#header nav a:hover {
background-color: #0882a1;
background-image: -moz-linear-gradient(top, #0782a0, #077d9b);
background-image: -webkit-linear-gradient(top, #0782a0, #077d9b);
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#0782a0), to(#077d9b));
background-image: -ms-linear-gradient(top, #0782a0, #077d9b);
background-image: -o-linear-gradient(top, #0782a0, #077d9b);
background-image: linear-gradient(top, #0782a0, #077d9b);
box-shadow: inset 0px 1px 5px 1px rgba(0,0,0,0.05), 0px 0px 5px 1px rgba(255,255,255,0.05);
}
You are missing value for css in line 80:
text-transform: ;
Plus html entities like $nbsp have ; at the end $nbsp;
Set body tag to:
body{
position:relative;
margin:0 auto;
width:1200px;
}
Next give #header-wrapper & #header WIDTH of 100%
#header-wrapper,#header{
width:100%;
}
This should keep your #header inside of your Wrapper, and Wrapper should remain inside of your Body.
/== TAB TEXT ==/
Try replacing your #header nav a with this
#header nav a {
float:left; <!-- Changed from display:inline-block; -->
text-decoration: none;
color: #fff;
padding: 0px 0px 0px 10px; <!-- changed from 0px 25px 0px 25px-->
outline: 0;
}

horizontal css menu <li> items repositioning under themselves if window is not in full screen

I have an issue with my CSS. The menu works fine but when you adjust the window from full screen to any other size, the menu cuts off at the right end and starts again on the left below the menu. I had a similar issue with a different page and I was able to fix it with position:absolute but this doesn't seem to resolve this. I'm not a beginner but I'm not a pro. If someone could help me figure out how to make the window scroll left to right instead of moving the menu options down, that would be great.
I have a div tag that my css menu goes in:
<div id='cssmenu' align='justify' style="z-index: 1;">
Then I have multiple menu's that go across the top of the page
<ul><br>
<li class='has-sub'> ~a href='index.html'>Home ~/a> ~/li>
<li class='has-sub'> ~a href='index.html'>General Info~/a> ~/li>
<li class='has-sub'> ~a href='index.html'>Downloads~/a> ~/li>
<li class='has-sub'> ~a href='index.html'> ~/a> ~/li>
<li class='has-sub'> ~a href='index.html'>Home ~/a> ~/li>
<li class='has-sub'> ~a href='index.html'>Home ~/a> ~/li>
<ul>
</code>
Here is my CSS.
#cssmenu ul,
#cssmenu li,
#cssmenu span,
#cssmenu a {
margin: auto;
padding: 0;
position: relative;
top: o;
z-index: 1;
}
#cssmenu {
height: 49px;
border-radius: 5px 5px 0 0;
-moz-border-radius: 5px 5px 0 0;
-webkit-border-radius: 5px 5px 0 0;
background: #fefefe;
background: -moz-linear-gradient(top, #fefefe 0%, #eee9f0 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #fefefe), color-stop(100%, #eee9f0));
background: -webkit-linear-gradient(top, #fefefe 0%, #eee9f0 100%);
background: -o-linear-gradient(top, #fefefe 0%, #eee9f0 100%);
background: -ms-linear-gradient(top, #fefefe 0%, #eee9f0 100%);
background: linear-gradient(top, #fefefe 0%, #eee9f0 100%);
border-bottom: 2px solid #a30813;
width: auto;
z-index: 1;
}
#cssmenu:after,
#cssmenu ul:after {
content: '';
display: block;
clear: both;
z-index: 1;
}
#cssmenu a {
background: #fefefe;
background: -moz-linear-gradient(top, #fefefe 0%, #ececec 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #fefefe), color-stop(100%, #ececec));
background: -webkit-linear-gradient(top, #fefefe 0%, #ececec 100%);
background: -o-linear-gradient(top, #fefefe 0%, #ececec 100%);
background: -ms-linear-gradient(top, #fefefe 0%, #ececec 100%);
background: linear-gradient(top, #fefefe 0%, #ececec 100%);
color: #000;
display: inline-block;
font-family: Helvetica, Arial, Verdana, sans-serif;
font-size: 12px;
line-height: 49px;
padding: 0 20px;
text-decoration: none;
z-index: 1;
}
#cssmenu ul {
list-style: none;
z-index: 1;
}
#cssmenu > ul {
float: left;
z-index: 1;
}
#cssmenu > ul > li {
float: left;
padding-left: 45px; /* This value moves the menu to the left*/
z-index: 1;
position: relative;
}
#cssmenu > ul > li > a {
color: #000;
font-size: 12px;
z-index: 1;
position: relative;
display:block;
}
#cssmenu > ul > li:hover:after {
content: '';
display: relative;
width: 0;
height: 0;
position: absolute;
left: 50%;
bottom: 0;
z-index: 0 !important;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
border-bottom: 10px solid #a30813;
margin-left: -10px;
float:left;
margin-top:0px !important;
z-index: 1;
}
#cssmenu > ul > li:first-child > a {
border-radius: 5px 0 0 0;
-moz-border-radius: 5px 0 0 0;
-webkit-border-radius: 5px 0 0 0;
float:left;
margin-top:0px !important;
z-index: 1;
}
#cssmenu > ul > li.active:after {
content: '';
display: block;
width: 0;
height: 0;
position: absolute;
left: 50%;
bottom: 0;
z-index: 1;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
border-bottom: 10px solid #a30813;
margin-left: -10px;
float:left;
margin-top:0px !important;
z-index: 1;
}
#cssmenu > ul > li.active > a {
-moz-box-shadow: inset 0 0 2px rgba(0, 0, 0, 0.1);
-webkit-box-shadow: inset 0 0 2px rgba(0, 0, 0, 0.1);
box-shadow: inset 0 0 2px rgba(0, 0, 0, 0.1);
background: #ececec;
background: -moz-linear-gradient(top, #ececec 0%, #ffeeff ef 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #ececec), color-stop(100%, #ffeeff ef));
background: -webkit-linear-gradient(top, #ececec 0%, #ffeeff ef 100%);
background: -o-linear-gradient(top, #ececec 0%, #ffeeff ef 100%);
background: -ms-linear-gradient(top, #ececec 0%, #ffeeff ef 100%);
background: linear-gradient(top, #ececec 0%, #ffeeff ef 100%);
z-index: 1;
margin-top:0px !important;
z-index: 1;
}
#cssmenu > ul > li:hover > a {
background: #ececec;
background: -moz-linear-gradient(top, #ececec 0%, #ffeeff ef 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #ececec), color-stop(100%, #ffeeff ef));
background: -webkit-linear-gradient(top, #ececec 0%, #ffeeff ef 100%);
background: -o-linear-gradient(top, #ececec 0%, #ffeeff ef 100%);
background: -ms-linear-gradient(top, #ececec 0%, #ffeeff ef 100%);
background: linear-gradient(top, #ececec 0%, #ffeeff ef 100%);
-moz-box-shadow: inset 0 0 2px rgba(0, 0, 0, 0.1);
-webkit-box-shadow: inset 0 0 2px rgba(0, 0, 0, 0.1);
box-shadow: inset 0 0 2px rgba(0, 0, 0, 0.1);
z-index: 1;
margin-top:0px !important;
z-index: 1 !important;
}
#cssmenu .has-sub {
z-index: 1;
padding-left: 50px;
z-index: 1;
}
#cssmenu .has-sub:hover > ul {
display: block;
z-index: 1;
padding-left: 50px;/* this value is used to align the menu*/
z-index: 1;
}
#cssmenu .has-sub ul {
display: none;
position: absolute;
width: 200px;
top: 100%;
left: 0;
z-index: 1;
}
#cssmenu .has-sub ul li {
*margin-bottom: -1px;
z-index: 1;
padding-left: 0px;
z-index: 1;
}
#cssmenu .has-sub ul li a {
background: #a30813;
border-bottom: 1px dotted #d40a19;
filter: none;
font-size: 11px;
display: block;
line-height: 120%;
padding: 10px;
color: #ffffff;
top:0;
z-index: 1;
}
#cssmenu .has-sub ul li:hover a {
background: #72060d;
margin-top:0px !important;
z-index: 1 !important;
padding-left:55px; /*this value moves the text to the left when highlighted*/
}
#cssmenu .has-sub .has-sub:hover > ul {
display: block;
margin-top:0px !important;
z-index: 1 !important;
padding-left:0; /* this keeps the sub-menu close to the drop down menu*/
}
#cssmenu .has-sub .has-sub ul {
display: none;
position: absolute;
left: 100%;
top:0;
z-index: 1;
}
#cssmenu .has-sub .has-sub ul li a {
background: #72060d;
border-bottom: 1px dotted #d40a19;
padding-left:5px; /* this aligns the txt to the left for the sub-menu */
z-index: 1;
}
#cssmenu .has-sub .has-sub ul li a:hover {
background: #5a040b;
margin-top:0px !important;
z-index: 1 !important;
padding-left:50px; /* this moves the text on the sub-menu when hovered over*/
}
Basically, the <li> element is floating left-to-right. It breaks off and starts on a new row when the width of the combined list-elements exceeds that of the <ul>.
What you can do is give the <div> a width:100% and overflow:hidden, so that you cannot see anything drop and start a new row.
Then you can give the <ul> a width:1000px, so that the <li> would be able to fit across the screen and be cut-off, but still somewhat visible. Here is what it would look like.
The problem after that is that you would need to resize the <li> items, either by font or padding; best to resize with media queries if working with multiple layouts. If you want them to resize dynamically, you can write a javascript function to handle the sizing/spacing.

How to align my dropdown menu to center of the page?

So if you want to see my menu go here.
Since I know you'll want my source, here's the HTML:
<div id='menu-container'>
<ul id='menu' class="menu">
<li class='active'><a href='/'><span>Home</span></a></li>
<li class='has-sub'><a href='/games/'><span>Games</span></a>
<ul>
<li><a href='/games/dota-2/'><span>Dota 2</span></a></li>
<li><a href='/games/cs-go/'><span>CS: GO</span></a></li>
<li><a href='/games/css/'><span>CS: Source</span></a></li>
<li><a href='/games/terraria/'><span>Terraria</span></a></li>
<li class='last'><a href='/games/minecraft/'><span>Minecraft</span></a></li>
</ul>
</li>
<li class='has-sub'><a href='/about.html'><span>About Us</span></a>
<ul>
<li><a href='http://www.youtube.com/user/'><span>Our YouTube Channel</span></a></li>
<li><a href='/faq-list.html'><span>Our FAQs/Q&A List</span></a></li>
<li><a href='/feed-news.rss'><span>Our RSS Feed</span></a></li>
<li><a href='/wiki/'><span>Our Wiki</span></a></li>
<li><a href='/wiki/'><span>Our Blog</span></a></li>
<li class='last'><a href='/privacy.html'><span>Privacy Policy</span></a></li>
</ul>
</li>
<li class='has-sub last'><a href='/contact.html'><span>Contact Us</span></a>
<ul>
<li class='last'><a href='/forums/'><span>Forums</span></a></li>
</ul>
</li>
</ul>
And here's my CSS:
* {
margin: 0px;
}
#menu-container ul,
#menu-container li,
#menu-container span,
#menu-container a {
margin: 0;
padding: 0;
position: relative;
}
#menu-container {
height: 49px;
border-radius: 0px 0px 0 0;
-moz-border-radius: 0px 0px 0 0;
-webkit-border-radius: 0px 0px 0 0;
background: #141414;
background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAxCAIAAACUDVRzAAAAA3NCSVQICAjb4U/gAAAALElEQVQImWMwMrJi+v//PxMDw3+m//8ZoPR/qBgDEhuXGLoeYswhXg8R5gAAdVpfoJ3dB5oAAAAASUVORK5CYII=) 100% 100%;
background: -moz-linear-gradient(top, #32323a 0%, #141414 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #32323a), color-stop(100%, #141414));
background: -webkit-linear-gradient(top, #32323a 0%, #141414 100%);
background: -o-linear-gradient(top, #32323a 0%, #141414 100%);
background: -ms-linear-gradient(top, #32323a 0%, #141414 100%);
background: linear-gradient(to bottom, #32323a 0%, #141414 100%);
border-bottom: 2px solid #0fa1e0;
}
#menu-container:after,
#menu-container ul:after {
content: '';
display: block;
clear: both;
}
#menu-container a {
background: #141414;
background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAxCAIAAACUDVRzAAAAA3NCSVQICAjb4U/gAAAALElEQVQImWMwMrJi+v//PxMDw3+m//8ZoPR/qBgDEhuXGLoeYswhXg8R5gAAdVpfoJ3dB5oAAAAASUVORK5CYII=) 100% 100%;
background: -moz-linear-gradient(top, #32323a 0%, #141414 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #32323a), color-stop(100%, #141414));
background: -webkit-linear-gradient(top, #32323a 0%, #141414 100%);
background: -o-linear-gradient(top, #32323a 0%, #141414 100%);
background: -ms-linear-gradient(top, #32323a 0%, #141414 100%);
background: linear-gradient(to bottom, #32323a 0%, #141414 100%);
color: #ffffff;
display: inline-block;
font-family: Helvetica, Arial, Verdana, sans-serif;
font-size: 12px;
line-height: 49px;
padding: 0 20px;
text-decoration: none;
}
#menu-container ul {
list-style: none;
}
#menu-container > ul {
float: left;
}
#menu-container > ul > li {
float: left;
}
#menu-container > ul > li:hover:after {
content: '';
display: block;
width: 0;
height: 0;
position: absolute;
left: 50%;
bottom: 0;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
border-bottom: 10px solid #0fa1e0;
margin-left: -10px;
}
#menu-container > ul > li:first-child > a {
border-radius: 0px 0 0 0;
-moz-border-radius: 0px 0 0 0;
-webkit-border-radius: 0px 0 0 0;
}
#menu-container > ul > li:last-child > a {
border-radius: 0 0px 0 0;
-moz-border-radius: 0 0px 0 0;
-webkit-border-radius: 0 0px 0 0;
}
#menu-container > ul > li.active > a {
box-shadow: inset 0 0 3px #000000;
-moz-box-shadow: inset 0 0 3px #000000;
-webkit-box-shadow: inset 0 0 3px #000000;
background: #070707;
background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAxCAIAAACUDVRzAAAAA3NCSVQICAjb4U/gAAAALklEQVQImWNQU9Nh+v//PxMDw3+m//8ZkNj/mRgYIHxy5f//Z0BSi18e2TwS5QG4MGB54HL+mAAAAABJRU5ErkJggg==) 100% 100%;
background: -moz-linear-gradient(top, #26262c 0%, #070707 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #26262c), color-stop(100%, #070707));
background: -webkit-linear-gradient(top, #26262c 0%, #070707 100%);
background: -o-linear-gradient(top, #26262c 0%, #070707 100%);
background: -ms-linear-gradient(top, #26262c 0%, #070707 100%);
background: linear-gradient(to bottom, #26262c 0%, #070707 100%);
}
#menu-container > ul > li:hover > a {
background: #070707;
background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAxCAIAAACUDVRzAAAAA3NCSVQICAjb4U/gAAAALklEQVQImWNQU9Nh+v//PxMDw3+m//8ZkNj/mRgYIHxy5f//Z0BSi18e2TwS5QG4MGB54HL+mAAAAABJRU5ErkJggg==) 100% 100%;
background: -moz-linear-gradient(top, #26262c 0%, #070707 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #26262c), color-stop(100%, #070707));
background: -webkit-linear-gradient(top, #26262c 0%, #070707 100%);
background: -o-linear-gradient(top, #26262c 0%, #070707 100%);
background: -ms-linear-gradient(top, #26262c 0%, #070707 100%);
background: linear-gradient(to bottom, #26262c 0%, #070707 100%);
box-shadow: inset 0 0 3px #000000;
-moz-box-shadow: inset 0 0 3px #000000;
-webkit-box-shadow: inset 0 0 3px #000000;
}
#menu-container .has-sub {
z-index: 1;
}
#menu-container .has-sub:hover > ul {
display: block;
}
#menu-container .has-sub ul {
display: none;
position: absolute;
width: 200px;
top: 100%;
left: 0;
}
#menu-container .has-sub ul li {
*margin-bottom: -1px;
}
#menu-container .has-sub ul li a {
background: #0fa1e0;
border-bottom: 1px dotted #6fc7ec;
filter: none;
font-size: 11px;
display: block;
line-height: 120%;
padding: 10px;
}
#menu-container .has-sub ul li:hover a {
background: #0c7fb0;
}
#menu-container .has-sub .has-sub:hover > ul {
display: block;
}
#menu-container .has-sub .has-sub ul {
display: none;
position: absolute;
left: 100%;
top: 0;
}
#menu-container .has-sub .has-sub ul li a {
background: #0c7fb0;
border-bottom: 1px dotted #6db2d0;
}
#menu-container .has-sub .has-sub ul li a:hover {
background: #095c80;
}
#menu-container {
-moz-box-shadow: 0 0 10px #888;
-webkit-box-shadow: 0 0 10px #888;
box-shadow: 0 0 10px #888;
}
It's much, but if I don't give it you'll report me so how to align the menu to the center of my page (since I didn't code this, it was my friend)? And I also want the menu only, without the empty grey space. Is it possible?
Here is a fiddle that shows you how to align your menu to the center of the screen. You can search for my changes in the css by searching for "EDITED". I marked all 3 changes that way.
Here is what I did.
1.Remove the rule that makes the whole menu float left :
#menu-container > ul {
float: left;
}
2.Specify on his parent element that you want it in the center of the page :
#menu-container {text-align:center;}
3.Then for each menu element, change the following rule :
#menu-container > ul > li {
float: left;
}
to
#menu-container > ul > li {
display: inline-block;
}
As for your last question (I also want the menu only, without the empty grey space), I don't understand what you mean. You want to remove the grey color from the menu bar?