Html 我的垂直文本居中对齐不起作用

Html 我的垂直文本居中对齐不起作用,html,css,Html,Css,我的代码有问题。我需要在每个框的中间垂直地对齐文本。 #navcontainer { padding: 0 5 20px 10px; } ul#navlist { font-family: sans-serif; } ul#navlist a { font-weight: bold; text-decoration: none; display: inline-block; line-height:20px vertical-align: midd

我的代码有问题。我需要在每个框的中间垂直地对齐文本。

#navcontainer {
    padding: 0 5 20px 10px;
}
ul#navlist {
    font-family: sans-serif;
}
ul#navlist a {
    font-weight: bold;
    text-decoration: none;
    display: inline-block;
    line-height:20px vertical-align: middle;
}
ul#navlist, ul#navlist ul, ul#navlist li {
    margin: 0 8px;
    padding: 0px;
    list-style-type: none;
    box-shadow: 8px 8px 12px #aaa;
}
ul#navlist li {
    float: left;
}
ul#navlist li a {
    color: #ffffff;
    background-color: #EF634A;
    //padding:10px;
    padding: 10px 5px 10px 5px;
    border: 1px #ffffff outset;
    height: 40px;
}
ul#navlist li a:hover {
    color: #ffff00;
    background-color: #003366;
}
ul#navlist li a:active {
    color: #cccccc;
    background-color: #003366;
    border: 1px #ffffff inset;
}
ul#subnavlist {
    display: none;
}
ul#subnavlist li {
    float: none;
}
ul#subnavlist li a {
    padding: 0px;
    margin: 0px;
    height: 20px;
}
ul#navlist li:hover ul#subnavlist {
    display: block;
    //display: inline-block;
    //display: table-cell;
    position: absolute;
    font-size: 8pt;
    padding-top: 5px;
}
ul#navlist li:hover ul#subnavlist li a {
    display: block;
    width : 260;
    height : 100;
    border: none;
    padding: 2px;
}
ul#navlist li:hover ul#subnavlist li a:before {
    content:" >> ";
}



这是小提琴

确保所有链接都是
display:block;宽度:100%;身高:100%以便填充父元素。确保父元素也具有
宽度:100%;身高:100%以便它们正确展开

要使文本本身居中,请参见以下问题:

1)使用li上的行距居中,然后将其恢复为锚定上的法线(以处理多行文本)

2)将padding/hover类放在li元素上,而不是锚点上

   ul#navlist li
   {
    padding: 10px 5px 10px 5px;
    background-color: #EF634A;
   }
   ul#navlist > li
   {
    height:62px; /* <----  */
    line-height:62px; /* <----  */
   }
    ul#navlist li:hover
    {
        color: #ffff00;
        background-color: #003366;
    }
    ul#navlist a
    {
    font-weight: bold;
    text-decoration: none;
    display: inline-block;
    line-height:normal; /* <----  */
    vertical-align: middle; /* <----  */
    }
ul#navlist li
{
填充:10px 5px 10px 5px;
背景色:#EF634A;
}
ul#navlist>li
{

高度:62px;/*请创建一个垂直对齐:中间;?垂直居中还是水平居中?文本对齐:中心将起作用我很确定他想要垂直对齐,因为框不够大,无法进行水平对齐//在css中不算作注释…只有/**/@LoganMurphy:使居中更简单,是的。好的!文本是真的在中间。唯一的问题是子菜单。每行的高度都是非常好的!如何减少子菜单blog中的阴影(见右边)谢谢!再次感谢。这是我一直在寻找的,如果这回答了你的问题-然后请投票并将其标记为答案;)好的!这很好。我希望把这个放在730像素的宽度内。我可以在这里调整哪个部分?
   ul#navlist li
   {
    padding: 10px 5px 10px 5px;
    background-color: #EF634A;
   }
   ul#navlist > li
   {
    height:62px; /* <----  */
    line-height:62px; /* <----  */
   }
    ul#navlist li:hover
    {
        color: #ffff00;
        background-color: #003366;
    }
    ul#navlist a
    {
    font-weight: bold;
    text-decoration: none;
    display: inline-block;
    line-height:normal; /* <----  */
    vertical-align: middle; /* <----  */
    }