CSS3 submenu's submenu dont work correctly - css

i have created a css3 style sheet for creating menu, in submenu of main menu is correct but after creating submenu. The child element of the submenu does not work correctly.
i want to move submenu's submenu to bottom of parent and i can move mouse cursor on child
JSFIDDLE
HTML:
<ul id="nav" class="nav" style='margin-right:0px;padding-right:0px;padding-top:0px;height:30px;'>
<li><a>MAIN MENU</a>
<ul>
<li>MENU 1
<ul>
<li><a>SUBMENU</a></li>
</ul>
</li>
<li>MENU 2</li>
<li>MENU 3</li>
</ul>
</li>
</ul>
CSS3:
#nav {
color: #fff;
margin: 0;
line-height: 100%;
padding-top: 4px;
padding-bottom: 4px;
height: 33px;
background: -moz-linear-gradient(center top , #5E9AE2, #3570B8) repeat scroll 0 0 transparent;
z-index: 10000;
}
#nav li {
margin: 0pt 5px;
padding: 2pt 0pt 5px;
float: right;
position: relative;
list-style: none outside none;
z-index: 10000;
cursor: pointer;
}
#nav a {
color: #fff !important;
text-decoration: none;
display: block;
padding: 9px 10px;
margin-right: 0pt;
border-radius: 5px 5px 5px 5px;
font-weight: normal;
z-index: 100000;
cursor: pointer;
}
#nav .current a, #nav li:hover > a {
z-index: 100000;
background: #fff ! important;
color: #000 ! important;
box-shadow: 0pt 1px 1px rgba(0, 0, 0, 0.2);
}
#nav ul li:hover a, #nav li:hover li a {
z-index: 100000;
background: none repeat scroll 0% 0% transparent;
color: #000 ! important;
box-shadow: none;
}
#nav ul a:hover {
background: -moz-linear-gradient(center top , rgb(198, 71, 53), rgb(147, 35, 19)) repeat scroll 0% 0% transparent ! important;
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#c44634), color-stop(100%,#952414)) repeat scroll 0% 0% transparent ! important; /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #c44634 0%,#952414 100%) repeat scroll 0% 0% transparent ! important; /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #c44634 0%,#952414 100%) repeat scroll 0% 0% transparent ! important; /* Opera 11.10+ */
background: -ms-linear-gradient(top, #c44634 0%,#952414 100%) repeat scroll 0% 0% transparent ! important; /* IE10+ */
background: linear-gradient(to bottom, #c44634 0%,#952414 100%) repeat scroll 0% 0% transparent ! important; /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#c44634', endColorstr='#952414',GradientType=0 ) ! important; /* IE6-9 */
color: rgb(255, 255, 255) ! important;
border-radius: 0pt 0pt 0pt 0pt;
text-shadow: 0pt 1px 1px rgba(0, 0, 0, 0.1);
cursor: pointer;
}
#nav ul {
background: #ffffff; /* Old browsers */
background: -moz-linear-gradient(top, #ffffff 0%, #cfcfcf 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffff), color-stop(100%,#cfcfcf)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #ffffff 0%,#cfcfcf 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #ffffff 0%,#cfcfcf 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #ffffff 0%,#cfcfcf 100%); /* IE10+ */
background: linear-gradient(to bottom, #ffffff 0%,#cfcfcf 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#cfcfcf',GradientType=0 ); /* IE6-9 */
display: none;
margin: 0pt;
padding: 0pt;
text-align: right;
width: 180px;/*طول منو*/
position: absolute;
top: 35px;
right: 0pt;
border-radius: 5px 5px 5px 5px;
direction: rtl;
box-shadow: 0pt 1px 3px rgba(0, 0, 0, 0.3);
}
#nav li:hover > ul {
display: block;
}
#nav ul li {
float: none;
margin: 0pt;
padding: 0pt;
}
#nav ul li ul{
float: none;
margin-top:28px;
margin-right: 180px;
top: 0px;
}
#nav ul li ul li:first-child > a {
border-radius: 5px 5px 5px 5px;
behavior: url('./css/PIE.htc');
}
#nav ul li ul li:last-child > a {
border-radius: 5px 5px 5px 5px;
behavior: url('./css/PIE.htc');
}
#nav ul a {
font-weight: normal;
text-shadow: 0pt 1px 1px rgba(255, 255, 255, 0.898);
}
#nav ul li:first-child > a {
border-top-left-radius: 5px;
border-top-right-radius: 5px;
border-radius: 5px 5px 0px 0px;
behavior: url('./css/PIE.htc');
}
#nav ul li:last-child > a {
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
border-radius: 0px 0px 5px 5px;
behavior: url('./css/PIE.htc');
}
#nav:after {
z-index: 100000;
content: ".";
display: block;
clear: both;
visibility: hidden;
line-height: 0pt;
height: 0pt;
}
this method not problem but i want to have any submenu and cant fix it.please help me,

#nav ul li ul {
float: none;
margin-right: 180px;
margin-top: 28px; /* <-- this is causing issue */
top: 0;
}

i don't know where the problem every thing work just remove margin-top
and add the html
<ul id="nav" class="nav" style='margin-right:0px;padding-right:0px;padding-top:0px;height:30px;'>
<li><a>MAIN MENU</a>
<ul>
<li>MENU 1
<ul>
<li><a>SUBMENU</a>
<ul>
<li><a>asdasd</a></li>
<li><a>asdasd</a></li>
<li><a>asdasd</a></li>
</ul>
</li>
</ul>
</li>
<li>MENU 2</li>
<li>MENU 3</li>
</ul>
</li>
see demo : jsfiddle

Related

CSS: custom bullets: joined as timeline

I am building a vertical timeline as a < ul > with the < li >s as events. This is the intent:
I've customized the bullets easily enough, and I made the vertical line with a background-gradient; the one thing I haven't been able to do is terminate the vertical line at top and bottom.
So far, it looks like this:
My SCSS code:
ul.timeline {
list-style: none;
color: red;
font-size: .8em;
/* Permalink - use to edit and share this gradient: http://colorzilla.com/gradient-editor/#ffffff+0,ffffff+5,d8d8d8+6,d8d8d8+7,ffffff+8,ffffff+100 */
background: #ffffff; /* Old browsers */
background: -moz-linear-gradient(left, #ffffff 0%, #ffffff 1px, #d8d8d8 2px, #d8d8d8 3px, #ffffff 4px, #ffffff 100%); /* FF3.6-15 */
background: -webkit-linear-gradient(left, #ffffff 0%,#ffffff 1px, #d8d8d8 2px, #d8d8d8 3px, #ffffff 4px,#ffffff 100%); /* Chrome10-25,Safari5.1-6 */
background: linear-gradient(to right, #ffffff 0%,#ffffff 1px, #d8d8d8 2px, #d8d8d8 3px, #ffffff 4px,#ffffff 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#ffffff',GradientType=1 ); /* IE6-9 */
background-position: 29px 0;
li {
&::before {
content: "\26AB";
font-size: 1.3em;
color: #d8d8d8;
display: inline-block;
width: 1em;
margin-left: -1em;
vertical-align: middle;
}
a {
color: black;
text-decoration: underline;
}
}
}
My HTML code:
<ul class="timeline">
<li>asd as</li>
<li>werwer we</li>
</ul>
I know I can scrap the whole custom-bullet and background-gradient css and do this with background-images, I was just hoping to find a css-only solution.
You can use pseudo-elements for this, one for circle and other one for the line, and :not(:last-child) so you don't set line on last element.
ul {
list-style: none;
}
li {
position: relative;
padding: 10px;
}
li a {
color: gray;
}
li:before {
content: '';
width: 16px;
height: 16px;
border-radius: 50%;
background: #D8D8D8;
position: absolute;
left: -15px;
top: 50%;
transform: translateY(-40%);
}
li:not(:last-child):after {
content: '';
width: 2px;
height: 100%;
background: #D8D8D8;
position: absolute;
left: -8px;
top: 50%;
}
<ul class="timeline">
<li>asd as</li>
<li>werwer we</li>
<li>werwer we</li>
</ul>
Method using background-gradient...
ul.timeline {
list-style: none;
color: red;
font-size: .8em;
position: relative;
}
.timeline::before {
position: absolute;
content: "";
display: block;
height: 80px;
width: 30px;
top: 6px;
left: 0;
background: radial-gradient(circle, grey 20%, transparent 20%);
background-size: 50px 25px;
}
.timeline::after {
position: absolute;
content: "";
display: block;
top: 8px;
left: 24px;
height: 70px;
width: 1px;
background: grey;
}
.timeline li {
padding: .5em;
}
a {
color: black;
text-decoration: underline;
}
<ul class="timeline">
<li>asd as</li>
<li>werwer we</li>
<li>werwer we</li>
</ul>

Bootstrap : prevent "nav-tabs nav-justified" from stacking on small screen

I'm using Twitter Bootstrap 3 and I have a sidebar and tabs in it.
<div class="col-md-4">
<div class="side-posts">
<ul class="nav nav-tabs nav-justified">
<li class=""><span data-icon=""></span> Recent</li>
<li class="active"><span data-icon=""></span> Popular</li>
</ul>
<div class="tab-content">
.....
</div>
</div>
</div>
When screen's width gets smaller the tabs stack on each other like this
Is it possible to keep the original look and prevent this change?
I had to write my own tabs style to get it work.
Here is a live bootply
in case link got broken here is the css:
/* CSS used here will be applied after bootstrap.css */
body{
background-color: #f2f2f2;
}
.container{
width: 325px;
}
.side-posts{
margin-top:15px;
}
.post-tabs{
padding:0;
margin-bottom:0;
list-style-type: none;
overflow: hidden;
}
.post-tabs li{
display: inline;
}
.post-tabs a{
display: block;
z-index: 1;
text-decoration: none;
padding: 10px 15px;
float: left;
width: 50%;
text-align:center;
border-bottom: 1px solid #dddddd;
text-shadow: 1px 1px 0 white;
transition:color 0.3s ease;
background: rgba(255,255,255,1);
background: -moz-linear-gradient(top, rgba(255,255,255,1) 0%, rgba(246,246,246,1) 47%, rgba(237,237,237,1) 100%);
background: -webkit-gradient(left top, left bottom, color-stop(0%, rgba(255,255,255,1)), color-stop(47%, rgba(246,246,246,1)), color-stop(100%, rgba(237,237,237,1)));
background: -webkit-linear-gradient(top, rgba(255,255,255,1) 0%, rgba(246,246,246,1) 47%, rgba(237,237,237,1) 100%);
background: -o-linear-gradient(top, rgba(255,255,255,1) 0%, rgba(246,246,246,1) 47%, rgba(237,237,237,1) 100%);
background: -ms-linear-gradient(top, rgba(255,255,255,1) 0%, rgba(246,246,246,1) 47%, rgba(237,237,237,1) 100%);
background: linear-gradient(to bottom, rgba(255,255,255,1) 0%, rgba(246,246,246,1) 47%, rgba(237,237,237,1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#ededed', GradientType=0 );
color:#3b5998;
}
.post-tabs a:hover{
color:#e95c40;
}
.post-tabs li.active a{
border-bottom: 0;
color: #444444;
z-index: 2;
}
.post-tabs li.active:first-child a {
border-right: 1px solid #dddddd;
box-shadow: inset -3px 0px 3px 0px rgba(0,0,0,0.4);
}
.post-tabs li.active:last-child a{
border-left: 1px solid #dddddd;
box-shadow: inset 3px 0px 3px 0px rgba(0,0,0,0.4);
}
.tab-content{
height:400px;
background-color: #dddddd;
}
You can add float:left; and remove float:none; editing the mobile media query inside bootstrap like:
#media (min-width: 768px){
.nav-tabs.nav-justified > li {
float: none;
}
}
#media (max-width: 768px){
.nav-tabs.nav-justified > li {
float: left;
}
}
DEMO http://jsfiddle.net/a_incarnati/52VtD/7771/
This worked perfectly for me, even keeps the default styling for bootstrap justified nav-bar.**
#media (max-width: 768px){
.nav-justified > li {
display: table-cell;
width: 1%;
}
.nav-justified > li > a {
border-bottom: 1px solid #ddd !important;
border-radius: 4px 4px 0 0 !important;
margin-bottom: 0 !important;
}
.nav-justified > li.active > a {
border-bottom: 1px solid transparent !important;
}
}

How to make navigation hover as background

I am UI UX Designer and big learner of CSS and HTML5, I am doing some practice but stuck in one thing:
Here is the screenshot I wish to build:
http://goo.gl/RK5i0y
(the mouse over effect)
HTML
<nav>
<ul>
<li>Home</li>
<li>Our Company</li>
<li>Services</li>
<li>Contact Us</li>
</ul>
</nav>
CSS
nav ul {
margin-top: 60px;
padding: 0;
float: right;
text-transform: uppercase;
}
nav ul li {
list-style: none;
float: left;
font-size:15px;
padding-right:57px;
}
header nav ul li a {
display: block;
color: #fff;
text-decoration: none;
/*font-weight: bold;*/
/*padding-right: 57px;*/
}
header nav ul li a:hover {
background: #00335a;
}
header nav ul li a:active {
-webkit-box-shadow: 0 0 5px rgba(0, 0, 0, 0.8) inset;
-moz-box-shadow: 0 0 5px rgba(0, 0, 0, 0.8) inset;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.8) inset;
}
How about this?
nav {
height: 160px;
background: linear-gradient(to bottom, #015190 0%,#014073 100%);
}
nav ul {
margin-top: 60px;
padding: 0;
float: right;
text-transform: uppercase;
}
nav ul li {
list-style: none;
float: left;
font-size:15px;
padding-right:30px;
}
nav ul li a {
display: block;
color: #fff;
text-decoration: none;
line-height: 40px;
padding: 0 20px;
font-weight: bold;
}
nav ul li a:hover {
background: linear-gradient(to bottom, #003e6d 0%,#003257 100%);
border-radius: 3px;
}
Please check this Fiddle: Demo
nav ul {
margin-top: 60px;
padding: 0;
float: right;
text-transform: uppercase;
}
nav ul li {
list-style: none;
float: left;
font-size:15px;
padding-right:57px;
}
nav ul li a {
display: block;
color: #000;
text-decoration: none;
padding: 10px;
/*font-weight: bold;*/
/*padding-right: 57px;*/
}
nav ul li a:hover {
background: #00335a;
color: #fff;
}
header nav ul li a:active {
-webkit-box-shadow: 0 0 5px rgba(0, 0, 0, 0.8) inset;
-moz-box-shadow: 0 0 5px rgba(0, 0, 0, 0.8) inset;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.8) inset;
}
Tinkerd with the previous one from ajc, jsfiddle.net/UypRf/16/ hope this give some better insight
I changed the code a little, but this script generates a navbar very much like your example picture:
HTML
<div class="header">
<img src="http://us.123rf.com/400wm/400/400/antoshkaforever/antoshkaforever1105/antoshkaforever110500039/9458039-template-to-mark-the-company-put-your-company-name-rather-than-text.jpg">
<div class="nav">
<ul>
<li>Home</li>
<li>Our Company</li>
<li>Services</li>
<li>Contact Us</li>
</ul>
</div>
</div>
CSS
body{
margin:0px;padding:0px;
}
div.header{
width:100%;
height:200px;
background-color: #444444;
background-image: -webkit-gradient(linear, left top, left bottom, from(#000099), to(#0000AA)); /* Chrome, Safari 4+ */
background-image: -webkit-linear-gradient(top, #444444, #999999); /* Chrome 10-25, iOS 5+, Safari 5.1+ */
background-image: -moz-linear-gradient(top, #444444, #999999); /* Firefox 3.6-15 */
background-image: -o-linear-gradient(top, #444444, #999999); /* Opera 11.10-12.00*/
background-image: linear-gradient(to bottom, #335599, #224477); /* Chrome 26, Firefox 16+, IE 10+, Opera 12.10+ */
}
div.header img{
margin:25px 5px;
max-height:150px;
}
div.header div.nav{
float:right;
margin-top:60px;
}
ul{
list-style-type:none;
margin:0;
padding:0;
overflow:hidden;
}
li
{
float:left;
}
a:link,a:visited{
font-family:Helvetica;
display:block;
color:#FFFFFF;
text-align:center;
padding:10px 20px;
text-decoration:none;
text-transform:uppercase;
}
a:hover,a:active
{
background-color:#223366;
}

How do i center menu items in CSS

I was trying to center the menu items in CSS. The bar takes up the whole width of the screen, which is a desired result. I want the menu items to get centered relative to the screen.
Here is the CSS that im using:
#cssmenu ul,
#cssmenu li,
#cssmenu span,
#cssmenu a {
margin: 0;
padding: 0;
position: relative;
}
#cssmenu {
height: 49px;
border-radius: 5px 5px 0 0;
-moz-border-radius: 5px 5px 0 0;
-webkit-border-radius: 5px 5px 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;
}
#cssmenu:after,
#cssmenu ul:after {
content: '';
display: block;
clear: both;
}
#cssmenu 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;
}
#cssmenu ul {
list-style: none;
}
#cssmenu > ul {
float: left;
}
#cssmenu > ul > li {
float: left;
}
#cssmenu > 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;
}
#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;
}
#cssmenu > ul > li:last-child > a {
border-radius: 0 5px 0 0;
-moz-border-radius: 0 5px 0 0;
-webkit-border-radius: 0 5px 0 0;
}
#cssmenu > 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%);
}
#cssmenu > 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;
}
#cssmenu .has-sub {
z-index: 1;
}
#cssmenu .has-sub:hover > ul {
display: block;
}
#cssmenu .has-sub ul {
display: none;
position: absolute;
width: 200px;
top: 100%;
left: 0;
}
#cssmenu .has-sub ul li {
*margin-bottom: -1px;
}
#cssmenu .has-sub ul li a {
background: #0fa1e0;
border-bottom: 1px dotted #6fc7ec;
filter: none;
font-size: 11px;
display: block;
line-height: 120%;
padding: 10px;
}
#cssmenu .has-sub ul li:hover a {
background: #0c7fb0;
}
#cssmenu .has-sub .has-sub:hover > ul {
display: block;
}
#cssmenu .has-sub .has-sub ul {
display: none;
position: absolute;
left: 100%;
top: 0;
}
#cssmenu .has-sub .has-sub ul li a {
background: #0c7fb0;
border-bottom: 1px dotted #6db2d0;
}
#cssmenu .has-sub .has-sub ul li a:hover {
background: #095c80;
}
Also, here is the HTML code that im using along with it:
<!DOCTYPE html>
<html lang="en">
<head>
<link href="menu_assets/styles.css" rel="stylesheet" type="text/css">
<link href="<?php echo base_url(); ?>menu_assets/styles.css" rel="stylesheet" type="text/css" />
<div id='cssmenu'>
<ul>
<li class='active'><a href='sample/home'><span>Home</span></a></li>
<li class='has-sub'><a href='#'><span>Upload Data</span></a>
<ul>
<li class='has-sub'><a href='sample/index'><span>Test Data</span></a>
<ul>
<li><a href='upload_form_att/index'><span>With Attachments</span></a></li>
<li class='last'><a href='sample/index'><span>Without Attachments</span></a></li>
</ul>
</li>
<li class='has-sub'><a href='#'><span>Protocol</span></a>
<ul>
<li><a href='#'><span>With Attachments</span></a></li>
<li class='last'><a href='#'><span>Without Attachments</span></a></li>
</ul>
</li>
</ul>
</li>
<li><a href='#'><span>Stability Data table</span></a></li>
<li><a href='#'><span>About</span></a></li>
<li class='last'><a href='#'><span>Logout</span></a></li>
</ul>
</div>
</head>
Any help would be appreciated.
EDIT: After making the changes suggested, I ran into another issue now. When i hove over the "sub menu" item, the "sub-sub menu" item is displayed with a gap and thus making them unclickable. Is there anything else that i need to edit to fix this?
In section should be set - margin-left: 25%;:
#cssmenu ul {
list-style: none;
margin-left: 25%;
}
Independently play around with this value.
In your html code was a mistake:
no tag and the web site body is placed in tag
Your HTML code corrected:
<!DOCTYPE html>
<html lang="en">
<head>
<link href="menu_assets/styles.css" rel="stylesheet" type="text/css">
<link href="styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id='cssmenu'>
<ul>
<li class='active'><a href='sample/home'><span>Home</span></a></li>
<li class='has-sub'><a href='#'><span>Upload Data</span></a>
<ul>
<li class='has-sub'><a href='sample/index'><span>Test Data</span></a>
<ul>
<li><a href='upload_form_att/index'><span>With Attachments</span></a></li>
<li class='last'><a href='sample/index'><span>Without Attachments</span></a></li>
</ul>
</li>
<li class='has-sub'><a href='#'><span>Protocol</span></a>
<ul>
<li><a href='#'><span>With Attachments</span></a></li>
<li class='last'><a href='#'><span>Without Attachments</span></a></li>
</ul>
</li>
</ul>
</li>
<li><a href='#'><span>Stability Data table</span></a></li>
<li><a href='#'><span>About</span></a></li>
<li class='last'><a href='#'><span>Logout</span></a></li>
</ul>
</div>
</body>
</html>
Add this to CSS file.
#cssmenu{
width:90%; //set according to you
margin:auto;
}
margin:auto automatically centers the element according to page and content width

2 100% width div, clear without using Top:

I'm running into a problem.
I know this is probably a noob mistake but bear with me.
I'm making two top bar menus at the top, I can place them using absolute positioning and top, however when the browser size changes it makes the top bar look messed up.
Is there a way to place these without using absolute position and top?
This is what I currently have:
THE HTML
<div id="nav">
<div class="logo"><h1>Health Numeric ©</h1>Live a Something Life</div>
<div style="display:inline-block">
<ul>
<li><img class="icons" src="img/icons/dashboard.png" />Dashboard</li>
<li><img class="icons" src="img/icons/patient.png" />Patients</li>
<li><img class="icons" src="img/icons/devices.png" />Devices</li>
<li><img class="icons" src="img/icons/account.png" />Account</li>
<li><img class="icons" src="img/icons/support.png" />Support</li>
</ul>
</div>
<div class="end"><strong>LifeView</strong> Portal</div>
</div>
<div id="subnav">
<span class="clientname">Patient: Brian Town</span>
</div>
<div id="bod">
<h1> test</h1>
</div>
The CSS
#nav h1 {
font: Verdana, Geneva, sans-serif;
font-size: 24px;
margin-bottom: 2px;
}
.logo {
width: 190px;
margin: auto 80px auto 50px;
display: inline-block;
vertical-align: top;
}
#nav {
position: fixed;
/*height: 65px;*/
width: 100%;
float: left;
left: 0px;
top: 0px;
margin: 0px;
padding: 0px;
color: #FFFFFF;
/* IE10 Consumer Preview */
background-image: -ms-linear-gradient(top, #0389FF 0%, #000000 100%);
/* Mozilla Firefox */
background-image: -moz-linear-gradient(top, #0389FF 0%, #000000 100%);
/* Opera */
background-image: -o-linear-gradient(top, #0389FF 0%, #000000 100%);
/* Webkit (Safari/Chrome 10) */
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #0389FF), color-stop(1, #000000));
/* Webkit (Chrome 11+) */
background-image: -webkit-linear-gradient(top, #0389FF 0%, #000000 100%);
/* W3C Markup, IE10 Release Preview */
background-image: linear-gradient(to bottom, #0389FF 0%, #000000 100%);
}
#nav ul {
list-style: none;
width: 450px;
margin: 0 auto;
padding: 0;
}
#nav li {
float: left;
}
#nav li a {
display: inline-block;
padding: 8px 15px;
text-decoration: none;
font-weight: bold;
color: #FFF;
border-right: 1px solid #ccc;
}
#nav li:first-child a {
border-left: 1px solid #ccc;
}
#nav li a:hover {
color: #23afff;
}
.end {
width: 200px;
margin: 10px auto auto 50px;
display: inline-block;
word-spacing: 20px;
vertical-align: top;
}
strong {
font: Verdana, Geneva, sans-serif;
font-size: 36px;
margin-bottom: 2px;
}
.icons {
display: block;
margin-left: auto;
margin-right: auto;
margin-bottom: 1px;
height: 35px;
width: 35px;
}
#subnav {
position: fixed;
overflow:hidden;
height: 20px;
width: 100%;
float: left;
left: 0px;
/*top: 65px;*/
margin: 0px;
padding: 0px;
border: 1px solid #333;
border-bottom: 1px solid #ccc;
color: #000000;
/* IE10 Consumer Preview */
background-image: -ms-linear-gradient(top, #666666 0%, #FFFFFF 100%);
/* Mozilla Firefox */
background-image: -moz-linear-gradient(top, #666666 0%, #FFFFFF 100%);
/* Opera */
background-image: -o-linear-gradient(top, #666666 0%, #FFFFFF 100%);
/* Webkit (Safari/Chrome 10) */
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #666666), color-stop(1, #FFFFFF));
/* Webkit (Chrome 11+) */
background-image: -webkit-linear-gradient(top, #666666 0%, #FFFFFF 100%);
/* W3C Markup, IE10 Release Preview */
background-image: linear-gradient(to bottom, #666666 0%, #FFFFFF 100%);
}
.clientname {
float: right;
margin-right: 120px;
color: #000000;
font-weight: bold;
}
#bod {
position: absolute;
width: 100%;
float: left;
left: 0px;
top: 85px;
margin: 0px;
padding: 0px;
color: #000000;
}
Here is a JSfiddle: http://jsfiddle.net/Artsen/HYZLR/
Thanks

Resources