Aligning text on a specific character

前端 未结 7 551
一生所求
一生所求 2020-12-05 19:19

I have this list of words i want to align on the center, every list item consists of two words divided by a \'-\'(hyphen). Is there an easy way i can align spot on the hyphe

7条回答
  •  臣服心动
    2020-12-05 20:04

    you could wrap your text in an inline-block boxe and set a width, reset text-align and give a negative margin to reduce virtually it's size to zero : http://jsfiddle.net/seLvC/2/

    .progress-ww {
      font-size: 0.8rem;
      line-height:0.8rem;
      text-align:center;
    }
    .progress-ww span {
        display:inline-block;
        width:100px;/* give it a width */
        margin:0 -100px 0 0;/* 0 space needed on right side */
        text-align:left;
    }
    .progress-ww span:first-of-type {
        margin:0 0 0 -100px;/* 0 space needed on left side */
        text-align:right
    }
    

    visual

    This would deserved to be tagged within

    list , as it's similar to a dictionnary. :)

提交回复
热议问题