本文介绍了如何删除CSS中元素的最后一个字母的字母间距?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的HTML网页的图片。
文本菜单位于右对齐的div中,并且具有1.2em字母间距。
有一个伪选择器吗?我不想求助于相对定位。

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 like to have to resort to relative positioning.

我会喜欢文本菜单结束块结束。

I would love the text menu to end where the block ends.

我已经标记了一个最好的答案,但是我被要求的标记,不管CodeBlock。这是它。

I've already marked a best answer, but I was asked for the markup regardless by CodeBlock. Here it is.

<div class="sidebar">
        <span class="menuheader">MENU</span>
        <ul>
        <li><a href="#content">Content</a></li>
        <li><a href="#attachments">Attachments</a></li>
        <li><a href="#subpages">Sub-pages</a></li>
        <li><a href="#newsubpage">New sub-page</a></li>
        </a></ul>
</div>

.sidebar{
color: rgb(150,93,101);
display: inline;
line-height: 1.3em;
position: absolute;
top: 138px;
width: 218px;
}

.menuheader{
letter-spacing: 1.1em;
margin: -1.2em;
text-align: right;
}


推荐答案

例如

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

要回答有关伪选择器的问题,伪选择器,据我所知。 (编辑:Scratch,有:First-Letter 选择器,Jonas G. Drange指出)。

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

编辑:您可以在这里找到一个基本示例:

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

这篇关于如何删除CSS中元素的最后一个字母的字母间距?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 10:52