CSS如何讓不相等的字元上下對齊,css相等字元對齊

來源:互聯網
上載者:User

CSS如何讓不相等的字元上下對齊,css相等字元對齊

最後效果:

<div class="main">      <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>    </div>
  <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>

本文來自:http://www.cnblogs.com/huhunet/p/6478649.html

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.