Centralized HTML / CSS Menu

1

I need a help with a code I do not know much about HTML and CSS , I'm learning slowly and need help.

  

Home HTML / CSS

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html  xml:lang="pt" lang="pt">

<head>
<title>Menu Horizontal</title>
<style type="text/css">
<!--
body {
padding:0px;
margin:0px;
}

#menu ul {
padding:0px;
margin:0px;
float: left;
width: 100%;
background-color:#EDEDED;
list-style:none;
font:80% Tahoma;
}

#menu ul li { display: inline; }

#menu ul li a {
background-color:#EDEDED;
color: #333;
text-decoration: none;
border-bottom:3px solid #EDEDED;
padding: 2px 10px;
float:left;
}

#menu ul li a:hover {
background-color:#D6D6D6;
color: #6D6D6D;
border-bottom:3px solid #EA0000;
}
-->
</style>
</head>

<body>
<div id="menu">
<ul>
<li><a href="">Home</a></li>
<li><a href="">Sobre</a></li>
<li><a href="">Artigos</a></li>
<li><a href="">Estudos</a></li>
<li><a href="">Diretório</a></li>
<li><a href="">CURSO</a></li>
<li><a href="">Links</a></li>
<li><a href="">Contato</a></li>
</ul>
</div>
</body>
</html>

This is the code that I have, but I can not put this menu always centered on the page, they could help me.

Thank you in advance

    
asked by anonymous 17.08.2016 / 15:55

1 answer

0

You should put the following changes in #menu ul , #menu ul li and #menu ul li a . Note that display: inline; does not allow you to give comprimento/altura to element, float: left; is unnecessary too.

body {
padding:0px;
margin:0px;
}

#menu ul {
padding:0px;
text-align: center;
margin: 0 auto;
width: 100%;
background-color:#EDEDED;
list-style:none;
font:80% Tahoma;
}

#menu ul li { display: inline-block; height: 100%;}

#menu ul li a {
background-color:#EDEDED;
color: #333;
text-decoration: none;
border-bottom:3px solid #EDEDED;
padding: 2px 10px;
display: block;
}

#menu ul li a:hover {
background-color:#D6D6D6;
color: #6D6D6D;
border-bottom:3px solid #EA0000;
}
<div id="menu">
<ul>
<li><a href="">Home</a></li>
<li><a href="">Sobre</a></li>
<li><a href="">Artigos</a></li>
<li><a href="">Estudos</a></li>
<li><a href="">Diretório</a></li>
<li><a href="">CURSO</a></li>
<li><a href="">Links</a></li>
<li><a href="">Contato</a></li>
</ul>
</div>
    
17.08.2016 / 16:03