How can I remove letter-spacing for the last letter of an element in CSS?

前端 未结 7 1753
一个人的身影
一个人的身影 2020-12-14 15:10

Here\'s the image in question of my HTML page. The text menu is inside a right aligned div, and has 1.2em letter spacing. Is there a pseudo-selector for this? I would not li

7条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-14 15:40

    You can set your element to have a right margin of -1.2em, which would counteract the letter spacing.

    e.g.

    .menu-header-selector {
      display:block;
      letter-spacing:1.2em;
      margin-right:-1.2em;
      text-align:right;
    }
    

    To answer your question regarding pseudo-selector, there isn't a per character pseudo-selector as far as I'm aware. (EDIT: Scratch that, there's the :First-Letter selector, which Jonas G. Drange pointed out).

    EDIT: You can find a basic sample here: http://jsfiddle.net/teUxQ/

提交回复
热议问题