自动适合li到文本的宽度? [英] Auto fit width of li to text?
本文介绍了自动适合li到文本的宽度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有可能使用CSS自动将< li>标签的宽度调整到它包含的文本的宽度?
Is there anyway possible to auto fit the width of an <li> tag to the width of the text it contains using CSS?
我正在设计一个使用自定义CMS的网站(我无法访问代码),因此就设计而言,我的选项有限。
I'm designing a website that uses a custom CMS (and I don't have access to the code), so I'm limited in options as far as design goes.
可以在< li>标签上运行而不必直接编辑任何列表属性的Javascript解决方案也可以。
Javascript solutions that would work on an <li> tag without having to edit any of the list properties directly would work as well.
推荐答案
正如@willoller已经说过的那样, li 元素是一个块级元素,但除了浮动它之外,你还可以使用:
As @willoller already said, the li element is a block level element, but apart from floating it, you can also use:
li {
display: inline;
}
这篇关于自动适合li到文本的宽度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文