Jump to content

Centering Horizontal Menu


Recommended Posts

I have prepared Horizontal menu for my website, I have utilised css3 to prepare my menu. Following are the code

 

<body> <ul> <li> <a href="http://www.spinfonet.com/jobs.html">Jobs</a> </li>
<li> <a href="http://www.spinfonet.com/matrimony.html">Matrimony</a> </li>
<li> <a href="http://mydomain.com/property.html">Property</a> </li> </ul><img alt="Splogo" src="Splogo.jpg">
<ul> <li> <a href="http://mydomain.com/aboutus.html">Aboutus</a> </li>
<li> <a href="http://mydomain.com/aboutfounder.html">Founder</a> </li>
<li> <a href="http://mydomain.com/contactus.html">Contactus</a> </li> </ul>
----------
css3 code
ul { list-style-type:none; margin:0 auto; padding:0; overflow:hidden; }
li { float:left }
a:link,a:visited { display:inline-block; text-align:center; width:150px; font-weight:700; color:#FFF; background-color:#98bf21; padding:0; text-decoration:none; text-transform:uppercase}
a:hover,a:active { background-color:#7A991A}
p { font-family:Times,Times New Roman; font-size:12px; margin:0; position:absolute; top:50%; margin-right:50%}
​I want to center my menu but same is not happening, how to do it?

Link to post
Share on other sites

This rul is probably the problem:

ul { list-style-type:none; margin:0 auto; padding:0; overflow:hidden;

ul is a block element and when no width is specified it defaults to width 100%. With width 100% there are no right an left margins. You need to specify the width to get the margins to have an impact.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...