Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 对中我的导航_Html_Navigation_Centering - Fatal编程技术网

Html 对中我的导航

Html 对中我的导航,html,navigation,centering,Html,Navigation,Centering,我需要在这个网站()中心导航,有什么想法吗?下面是代码,我试着使用inspect元素工具,但我无法解决它。代码看起来很简单,但我不知道如何使用JSFIDLE。如果您能帮上忙,我们将不胜感激。谢谢 /* Navigation --------------------------------------------------------------------------------*/ #topnav { clear: both; text-align:center;

我需要在这个网站()中心导航,有什么想法吗?下面是代码,我试着使用inspect元素工具,但我无法解决它。代码看起来很简单,但我不知道如何使用JSFIDLE。如果您能帮上忙,我们将不胜感激。谢谢

/* Navigation --------------------------------------------------------------------------------*/

#topnav {
    clear: both;
    text-align:center;
    background: url(nav-left.png) no-repeat;
    padding-left: 8px;
    width: 971px;
}

#nav-right {
    background: url(nav-right.png) right top no-repeat;
    padding-right: 10px;
}

#nav-inner {
    background: url(nav-inner.png) repeat-x;
    padding: 2px 5px 3px;
}

#topnav ul {
    list-style: none;
    float: none;
    background: url(nav-sep.jpg) no-repeat left center;
}

#topnav ul li {
    list-style: none;
    float: left;
    background: url(nav-sep.jpg) no-repeat right center;
    padding-right: 2px;
}

#topnav a {
    float: left;
    text-align:center;
    display: block;
    color: #989899;
    text-decoration: none;
    padding: 19px 38px;
    border: 0;
    outline: 0;
    list-style-type: none;
    font-size: .9em;
}

#topnav li#active a,
#topnav a:hover {
    transition: 0.5s; 
    -moz-transition: 0.5s; 
    -webkit-transition: 0.5s; 
    -o-transition: 0.5s; 
    color: #ed53ae;
    background: #090909 url(nav-active.png);
    border: 0;
}

我建议让孩子
ul
元素
内联块

#nav-inner > ul {
    display: inline-block;
}
然后将
text align:center
添加到父元素
#nav internal

#nav-inner {
    text-align: center;
    background: url(theme/nav-inner.png?486154) repeat-x;
    padding: 2px 5px 3px;
}
这将确保菜单无论尺寸大小都居中-有利于动态内容(即,您不必设置固定宽度并使用
边距:0 auto