鍍金池/ 問答/HTML5  HTML/ css3中的字間距問題

css3中的字間距問題

哪位大神開發(fā)有經(jīng)驗(yàn)的傳授下,如何做到這種效果的字間距的問題哈,給一個(gè)寬度,剛好是4個(gè)字的寬度,那么,2個(gè)字如何恰當(dāng)?shù)淖龅揭矒伍_4個(gè)字的間距呢?我嘗試用過letter-spacing: 0.5em;但是用這種方式還是有點(diǎn)偏差的,個(gè)人覺得這方式可能我用的不對(duì),還有更好的方式么??

clipboard.png

回答
編輯回答
葬憶

css

 .letter-2 {
  margin: 0 6px;
}

 .letter-3 {
  margin-left: 24px;
}

html

<dt>收<span class="letter-2">貨</span>人:</dt>
2017年6月7日 11:02
編輯回答
下墜

一個(gè)字的字體大小乘以2讓后給letter-spacing

2017年7月7日 04:35
編輯回答
故林

原答案鏈接:https://segmentfault.com/q/10...

<label for="contact">
  <span>聯(lián)系人</span>
  <input type="text" id="contact">
</label>
  
<label for="phoneNumber">
  <span>手機(jī)號(hào)碼</span>
  <input type="phoneNumber">
</label>  

<label for="verifyCode">
  <span>驗(yàn)證碼</span>
  <input type="text" id="verfiyCode">
</label> 
label{
  display: block;
  margin: 20px;
}

label > span{
  position: relative;
  width: 96px;
  text-align: justify;
  float: left;
  margin-top: 1em;
  height: 1em;
}

label > span::before{
  content: '*';
  position: absolute;
  font-size: 24px;
  left: -1em;
  color: orange;
  line-height: 0;
  top: .5em;
}

label > span::after{
  content: '';
  display: inline-block;
  width: 100%;
}

label > input{
  width: 210px;
  padding: 10px 20px;
  margin-left: 20px;
  font-size: 1em;
}
2017年5月6日 09:56
編輯回答
哎呦喂

看了樓上的評(píng)論,嗯,你還可以試試這樣(/滑稽臉):
html:

<label><span>性</span><span>別</span></label>

css:

label {
    display: flex;
    justify-content:space-between
}
2017年3月24日 12:26
編輯回答
陌如玉

試下display: inline-block

2017年12月8日 03:53
編輯回答
玩控

額,我一般都是“性別”中間插兩個(gè)&emsp;(全角空白),“有效期”中間的空白部分各插一個(gè)&ensp;(半角空白),雖然不太優(yōu)雅但是勝在兼容好……

2018年9月16日 16:15
編輯回答
絯孑氣
<style>
    .label {
        display: inline-block;
        width: 4em;
        text-align-last: justify;
    }
</style>
    
<div>
    <span class="label">性別</span>
</div>
<div>
    <span class="label">出生日期</span>
</div>
2018年8月6日 03:01