參考:https://blog.csdn.net/muyutin...css
<span style="font-size:12px;"><dl class="hotsearch" style="width:300px;"> <dt>熱門搜索</dt> <dd><a href="#" target="_blank" ref="nav" class="w3">電視機</a></dd> <dd><a href="#" target="_blank" ref="nav" class="w4">性感漂亮</a></dd> <dd><a href="#" target="_blank" ref="nav" class="w3">高跟鞋</a></dd> <dd><a href="#" target="_blank" ref="nav" class="w2">手機</a></dd> <dd><a href="#" target="_blank" ref="nav" class="w2">對齊</a></dd> <dd><a href="#" target="_blank" ref="nav" class="w3">牛仔褲</a></dd> <dd><a href="#" target="_blank" ref="nav" class="w4">小家碧玉</a></dd> <dd><a href="#" target="_blank" ref="nav" class="w2">家居</a></dd> </dl></span>
<style type="text/css"> .hotsearch dd{ float: left; line-height: 24px; margin-right: 30px; overflow: hidden; text-align: center; width: 4em; /*這個值是看最長能顯示幾個文字,如x,則爲x em*/ } .hotsearch dd a{ display:block; } .w2{ letter-spacing:2em; /*若是須要y個字兩端對齊,則爲(x-y)/(y-1),這裏是(4-2)/(2-1)=2em */ margin-right:-2em; /*同上*/ } .w3{ letter-spacing:0.5em; /*若是須要y個字兩端對齊,則爲(x-y)/(y-1),這裏是(4-3)/(3-1)=0.5em */ margin-right:-0.5em; /*同上*/ } </style> }
<text style="opacity: 0;">空格</text>
html
text-align:justify; width:100px;