如何呈现< li>并排? [英] How do I render <li> side-by-side?

查看:103
本文介绍了如何呈现< li>并排?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要创建一个导航菜单,列表项目呈现在一行。我如何做到这一点?

I'm looking to create a navigation menu with list items rendered in one line. How do I do this?

推荐答案

li {
    display: inline;
}

EDIT:回答 display:inline :因为我通常使用 float:left 自己,这是anthony-arnold的回答

I now realize why I felt strange answering with display: inline: because I usually use float: left myself instead, which is anthony-arnold's answer (so to him goes my upvote!).

无论如何,任何一种方法都会使你的 li 显示在一个线,内联元素和浮动元素的行为不同。根据您的布局样式,您可能必须选择其中一个。

Anyway, while either method will cause your lis to display in one line, inline elements and floated elements do behave differently. Depending on how you've styled your layout, you may have to choose one or the other.

这篇关于如何呈现< li>并排?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆