我们可以给li赋宽度 [英] can we assign width to li
本文介绍了我们可以给li赋宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下html页面与UL和LI,我尝试分配宽度给每个LI,但不能看到成功
i have following html page with UL and LI, i try to assign width to each LI but can't see cay success
<html>
<head>
<style type="text/css">
ul
{
overflow-x:hidden;
white-space:nowrap;
height: 1em;
width: 100%;
}
li
{
display:inline;
padding-right:10px;
}
</style>
</head>
<body>
<ul>
<li style="width:100px">abcdefghijklmonpqrstuvwxyz</li>
<li>abcdefghijklmonpqrstuvwxyz</li>
<li>abcdefghijklmonpqrstuvwxyz</li>
<li>abcdefghijklmonpqrstuvwxyz</li>
<li>abcdefghijklmonpqrstuvwxyz</li>
<li>abcdefghijklmonpqrstuvwxyz</li>
<li>abcdefghijklmonpqrstuvwxyz</li>
</ul>
</body>
</html>
,因为我的每个LI都有不同的宽度。
because each of my LI has different width.
感谢
推荐答案
不,您不能将宽度指定为内联显示的内容, LI
即可。相反,你最经常想使用 display:block; float:left;
其中允许设置宽度。
No, you can't assign width to anything that is displayed inline, which you've set your LI
to be. Instead, you most often want to use display: block; float: left;
which'll allow for setting width.
这篇关于我们可以给li赋宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文