Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何在列表中制作独立的自动宽度?现在,如果我在ul中为li设置width:auto,则li扩展为 100%。我怎样才能达到像下面这样的自动宽度?
您可以使用float和clear属性:
float
clear
li { background: #999; clear:left; float:left; }
jsFiddle 示例