Css menu problem

  1. why without <a href=“#”>text</a> i see like this ?

  2. how to do all menu in center ? not rigth now (left)

the css

/* navigation style */
#nav{
	height: 39px;
	font: 12px Geneva, Arial, Helvetica, sans-serif;
	background: #5eb974;
	border: 1px solid #5eb974;	
	border-radius: 3px;
	min-width:500px;
	margin-left: 0px;
	padding-left: 0px;
}	


#nav li{
	list-style: none;
	display: block;
	float: left;
	height: 40px;
	position: relative;
	border-right: 1px solid #5eb974;
}

#nav li a{
	padding: 0px 10px 0px 30px;
	margin: 0px 0;
	line-height: 40px;
	text-decoration: none;
	border-right: 1px solid #83ffa1;
	height: 40px;
	color: #FFF;
	text-shadow: 1px 1px 1px #66696B;
}

#nav ul{
	background: #f2f5f6; 
	padding: 0px;
	border-bottom: 1px solid #DDDDDD;
	border-right: 1px solid #DDDDDD;
	border-left:1px solid #DDDDDD;
	border-radius: 0px 0px 3px 3px;
	box-shadow: 2px 2px 3px #ECECEC;
	-webkit-box-shadow: 2px 2px 3px #ECECEC;
    -moz-box-shadow:2px 2px 3px #ECECEC;
	width:170px;
}

#nav li.main{
	background: url(pic/main/index/home_icon.png) no-repeat 9px 12px;
}
#nav li.main:hover  {
	background: url(pic/main/index/home_icon.png) no-repeat 9px 12px #36bb56;
}
#nav li.product{
	background: url(pic/main/index/tea.png) no-repeat 9px 12px;
}
#nav li.product:hover  {
	background: url(pic/main/index/tea.png) no-repeat 9px 12px #36bb56;
}

#nav li.action{
	background: url(pic/main/index/action.png) no-repeat 9px 12px;
}
#nav li.action:hover  {
	background: url(pic/main/index/action.png) no-repeat 9px 12px #36bb56;
}

#nav li.news{
	background: url(pic/main/index/news.png) no-repeat 9px 12px;
}
#nav li.news:hover  {
	background: url(pic/main/index/news.png) no-repeat 9px 12px #36bb56;
}

#nav li.faq{
	background: url(pic/main/index/faq.png) no-repeat 9px 12px;
}
#nav li.faq:hover  {
	background: url(pic/main/index/faq.png) no-repeat 9px 12px #36bb56;
}

#nav li.contacts{
	background: url(pic/main/index/contact.png) no-repeat 9px 12px;
}
#nav li.contacts:hover  {
	background: url(pic/main/index/contact.png) no-repeat 9px 12px #36bb56;
}

#nav li.usercp{
	background: url(pic/main/index/faq.png) no-repeat 9px 12px;
}
#nav li.usercp:hover  {
	background: url(pic/main/index/faq.png) no-repeat 9px 12px #36bb56;
}

#nav li.administration{
	background: url(pic/main/index/faq.png) no-repeat 9px 12px;
}
#nav li.administration:hover  {
	background: url(pic/main/index/faq.png) no-repeat 9px 12px #36bb56;
}

#nav li:hover{
	background: #36bb56;
}
#nav li a{
	display: block;
}
#nav ul li {
	border-right:none;
	border-bottom:1px solid #DDDDDD;
	width:170px;
	height:39px;
	text-align: left;
	background: url(pic/main/index/sub_cat.png) no-repeat 9px 12px;
}
#nav ul li:hover{
	background: #DFEEF0;
	background: url(pic/main/index/sub_cat.png) no-repeat 9px 12px;
}
#nav ul li a {
	border-right: none;
	border-left: none;
	color:#6791AD;
	text-shadow: 1px 1px 1px #FFF;
	border-bottom:1px solid #FFFFFF;
}

#nav ul li:last-child {
border-bottom: none;
}
#nav ul li:last-child a{
border-bottom: none;
}

/* Sub menus */
#nav ul{
	display: none;
	visibility:hidden;
	position: absolute;
	top: 40px;
}

/* Third-level menus */
#nav ul ul{
	top: 0px;
	left:170px;
	display: none;
	visibility:hidden;
	border: 1px solid #DDDDDD;
}
/* Fourth-level menus */
#nav ul ul ul{
	top: 0px;
	left:170px;
	display: none;
	visibility:hidden;
	border: 1px solid #DDDDDD;
}

#nav ul li{
	display: block;
	visibility:visible;
}
#nav li:hover > ul{
	display: block;
	visibility:visible;
}

html + jquery

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
	$("#nav li").hover(
	function(){
		$(this).children('ul').hide();
		$(this).children('ul').slideDown('fast');
	},
	function () {
		$('ul', this).slideUp('fast');            
	});
});
</script>
<ul id="nav">
    <li class="main"><a href="./">&#1043;&#1083;&#1072;&#1074;&#1085;&#1072;&#1103;</a></li>
	<li class="news"><a href="#">&#1053;&#1086;&#1074;&#1086;&#1089;&#1090;&#1080;</a>
            <ul>
                <li><a href="#">&#1057;&#1072;&#1081;&#1090;&#1072;</a></li>
                <li><a href="#">&#1050;&#1086;&#1084;&#1087;&#1072;&#1085;&#1080;&#1080;</a></li>
            </ul>
    </li>
	<li class="product"><a href="#">&#1058;&#1086;&#1074;&#1072;&#1088;</a>
            <ul>
			    <li><a href="?cat=1">&#1063;&#1072;&#1081; &#1053;&#1077;&#1082;&#1090;&#1072;&#1088; &#1041;&#1086;&#1075;&#1086;&#1074;</a></li>
                <li><a href="?cat=2">&#1063;&#1072;&#1081; CERERA</a></li>
				<li><a href="?cat=3">&#1063;&#1072;&#1081; &#1055;&#1086;&#1093;&#1091;&#1076;&#1077;&#1081;</a></li>
            </ul>
    </li>
<?
if ($CURUSER) { 
print("<li class=\\"usercp\\"><a href=\\"./\\">&#1055;&#1088;&#1086;&#1092;&#1080;&#1083;&#1100;</a>
            <ul>
                <li><a href=\\"#\\">&#1050;&#1086;&#1085;&#1092;&#1080;&#1075;&#1091;&#1088;&#1072;&#1094;&#1080;&#1103;</a></li>
                <li><a href=\\"#\\">&#1048;&#1089;&#1090;. &#1079;&#1072;&#1082;&#1072;&#1079;&#1086;&#1074;</a></li>
            </ul>
    </li>");
if (get_user_class() >= UC_SYSOP) {
print("<li class=\\"administration\\"><a href=\\"./\\">&#1055;&#1072;&#1085;&#1077;&#1083;&#1100; &#1040;&#1076;&#1084;&#1080;&#1085;.</a>
            <ul>
                <li><a href=\\"#\\">&#1056;&#1077;&#1076;. &#1087;&#1088;&#1086;&#1092;&#1080;&#1083;&#1100;</a></li>
                <li><a href=\\"#\\">&#1048;&#1089;&#1090;. &#1079;&#1072;&#1082;&#1072;&#1079;&#1086;&#1074;</a></li>
            </ul>
    </li>");
}
} 
?>
    <li class="action"><a href="#">&#1040;&#1082;&#1094;&#1080;&#1080;</a>
        <ul>
        <li><a href="#">&#1055;&#1088;&#1086;&#1084;&#1086; &#1050;&#1086;&#1076;&#1099; &raquo;</a>            
            <ul>
                <li><a href="#">&#1056;&#1077;&#1075;&#1080;&#1089;&#1090;&#1088;&#1072;&#1094;&#1080;&#1103; &#1050;&#1086;&#1076;&#1072;</a></li>
                <li><a href="#">&#1055;&#1088;&#1072;&#1074;&#1080;&#1083;&#1072; &#1040;&#1082;&#1094;&#1080;&#1080;</a></li>
                <li><a href="#">&#1055;&#1088;&#1080;&#1079;&#1086;&#1074;&#1086;&#1081; &#1060;&#1086;&#1085;&#1076;</a></li>
                <li><a href="#">&#1055;&#1086;&#1073;&#1077;&#1076;&#1080;&#1090;&#1077;&#1083;&#1080; &raquo;</a>
                <ul>
                    <li><a href="#">&#1055;&#1091;&#1090;&#1077;&#1074;&#1082;&#1080; &#1074; &#1048;&#1079;&#1088;&#1072;&#1080;&#1083;&#1100;</a></li>
                    <li><a href="#">&#1063;&#1072;&#1081;&#1085;&#1080;&#1082;&#1072;</a></li>
					<li><a href="#">&#1058;&#1091;&#1072;&#1083;&#1077;&#1090;&#1085;&#1086;&#1081; &#1041;&#1091;&#1084;&#1072;&#1075;&#1080;</a></li>
                </ul>
                </li>
            </ul>
		</li>
        <li><a href="#">&#1056;&#1077;&#1082;&#1083;&#1072;&#1084;&#1072;</a></li>
        <li><a href="#">&#1040;&#1088;&#1093;&#1080;&#1074; &#1072;&#1082;&#1094;&#1080;&#1081;</a></li>
        </ul>
    </li> 
	<li class="faq">&#1063;&#1072;&#1089;&#1090;&#1099;&#1077; &#1074;&#1086;&#1087;&#1088;&#1086;&#1089;&#1099;</li>
    <li class="contacts"><a href="#">&#1050;&#1086;&#1085;&#1090;&#1072;&#1082;&#1090;&#1099;</a>
        <ul>
        <li><a href="#">&#1048;&#1085;&#1092;&#1086;&#1088;&#1084;&#1072;&#1094;&#1080;&#1103;</a></li>
        <li><a href="#">&#1054;&#1073;&#1088;&#1072;&#1090;&#1085;&#1072;&#1103; &#1089;&#1074;&#1103;&#1079;&#1100;</a></li>
        <li><a href="#">&#1046;&#1072;&#1083;&#1086;&#1073;&#1099;</a></li>
        </ul>
    </li>
</ul>

Thanks

Don’t need answer for first, i found way with just do <a>text<a/> and it’s work.

Need only answer for my second question :slight_smile:

Hi,

To center the menu easily add a wrapper to the nav and change the #nav style to this:


/* navigation style */
#navwrap{
	height: 39px;
	font: 12px Geneva, Arial, Helvetica, sans-serif;
	background: #5eb974;
	border: 1px solid #5eb974;	
	border-radius: 3px;
	min-width:500px;
	text-align:center;/* center inline-block child */
}
#nav{
	height: 39px;
	background: #5eb974;
	margin:0;
	padding:0;
	list-style:none;
	text-align:left;/* reset text to left */
	display:inline-block;
	*display:inline;/* remove if ie7 and under support not required */
	zoom:1.0;
}	
 

(#navwrap is a new style and #nav completely replaces your #nav rule.)

html:


<div id="navwrap">
		<ul id="nav">
                 ... etc ...
		</ul>
</div>


I’m not sure what you were asking in question 1 but if you want an item that is not a link the best thing to do is to place it in a span instead and style the span with the same rules that you do for the anchors.

e.g.


#nav li a ,#nav li span{
	padding: 0px 10px 0px 30px;
	margin: 0px 0;
	line-height: 40px;
	text-decoration: none;
	border-right: 1px solid #83ffa1;
	height: 40px;
	color: #FFF;
	text-shadow: 1px 1px 1px #66696B;
	display:block;
}


<li class="faq"><span>&#1063;&#1072;&#1089;&#1090;&#1099;&#1077; &#1074;&#1086;&#1087;&#1088;&#1086;&#1089;&#1099;</span></li>

Thank you, work :slight_smile: I see you very good :smiley: so i give you one more question (see in image) :goof:

Thanks

Hi,

You can remove the last border from the list using :last-child for ie9+ like so.


#nav li a ,#nav li span{
	padding: 0px 10px 0px 30px;
	margin: 0px 0;
	line-height: 40px;
	text-decoration: none;
	border-right: 1px solid #83ffa1;
	height: 40px;
	color: #FFF;
	text-shadow: 1px 1px 1px #66696B;
	display:block;
}

#nav > li:last-child > a ,#nav > li:last-child > span{border-right:none}

However as you already have a class on the last item (.contacts) you can use that instead which will work for al browsers.


#nav > li.contacts > a ,#nav > li.contacts > span{border-right:none}

Wow! Work perfect! Thank you very much CSS SENSEI for all! :D:)