开发者

Horizontal <ul> menu: how to fix the width of list items

I have a horizontal开发者_高级运维 <ul> menu. How can I fix the width of the <li> elements at, say, 250px each?


Styling the A tag can help maintain consistency and give you a little more flexibility than styling the LI tag, espeically if you end up making multi-line menu items.

ul li {
   float:left;
}

ul li a {
   display:block;
   width:250px;
}

You should also use a CSS reset to maintain consistency between browsers.


You can do this via CSS:

ul > li { width: 250px; }

Depending on your you're doing the horizontal menu, you may need a display:block; style as well.


What Nick and Diodeus both say is right, but unless you want all of your list items to have that width, you better throw an id on that ul and then target it in your CSS.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜