css布局 li 不设宽度 不让文字竖排

html-css03

css布局 li 不设宽度 不让文字竖排,第1张

<style>

.box{width:400pxheight:autofloat:left}

ul{margin:0padding:0list-style:none inside}

ul li{position:relative}

</style>

以前我也遇到过这个问题,整了好长时间才发现position:relative这个属性的,你试一下!我已经试过了!

li内的文字变成竖向了,可以通过css对LI的样式进行定义和修改:

1、给Li设置浮动。加上 float:left

2、对LI设置好相应的宽度width和高度height

3、通过overflow:hidden对超出li宽度的隐藏

相应代码为:

li{float:leftwidth:200pxheight:30pxline-height:30pxoverflow:hidden}