好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

请大家帮我看一下我这段代码中的ul和a为什么不能显示在同一行中。_html/css_WEB-ITno

我现在用ul做了一个横向菜单,想把它放在“home”连接的右边,但我发现它运行时ul菜单始终会换行,是不是css出了问题,请大家给我指教一下,谢谢。建议用firefox浏览器运行。







ul { padding:0; margin:0; list-style:none;}
li { float:left; width:140px; }
ul li a { text-decoration:none; color:#777;}
li:hover { background-color:#ddd;}
ul li ul li table{ background-color:#ddd;}
li ul { display:none;}
li:hover ul,.over ul { display:block;}




Home

|


menu1

test1
test2
test3
test4


menu2

test5
test6






回复讨论(解决方案)

在线等,请大家帮忙。

ul是块级元素,当然会换行,你可以强制它inline,其它自己调吧。
ul { display:inline}

把css的最后一行改成li:hover ul,.over ul { display:inline;}也不行,没办法只能用类似下面的坐标定位来调整了:
ul{
position:absolute;
top: 10px;
margin-left:100px;
}

                          ul { padding:0; margin:0; list-style:none;display: inline;}        li { float:left; width:140px; }        ul li a { text-decoration:none; color:#777;}        li:hover { background-color:#ddd;}        ul li ul li table{ background-color:#ddd;}        li ul { display:none;}        li:hover ul,.over ul { display:block;}       

Home |

查看更多关于请大家帮我看一下我这段代码中的ul和a为什么不能显示在同一行中。_html/css_WEB-ITno的详细内容...

  阅读:34次