文本溢出:省略号对齐问题

Ale*_*rin 1 html css truncate rich-snippets

我将产品名称和定价作为单独的跨度包含在链接中,以便与 Rich Snippets 正常工作。有些产品的名称长度比其他产品大,所以我截断了长度,使其适合我的盒子。以前这是在服务器上完成的,但我更喜欢用 CSS 处理它,这样对设计的任何更改都不会涉及后端页面的更改。

在此处输入图片说明

问题是我不能让跨度排列在一起。修改 display 属性后, text-overflow 属性不起作用。有问题的代码如下:

HTML:

<div class="details" itemscope itemtype="http://data-vocabulary.org/Product"> 
<h2>
    <a class="heading" href="/product/acmesw" title="Acme Super Widget">
        <span class="trunc" itemprop="name">Acme Super Widget 3000</span>
        <span itemprop="offerDetails" itemscope itemtype="http://data-vocabulary.org/Offer">- <meta itemprop="currency" content="AUD" /><spanitemprop="price">$199.95</span></span>     
     </a>
 </h2>
Run Code Online (Sandbox Code Playgroud)

CSS:

.details {
    width:300px;
    border:1px solid red;
}
.trunc {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width:60%;
}

h2 span {
    display:inline-block;
}
Run Code Online (Sandbox Code Playgroud)

jsFiddle在这里:http : //jsfiddle.net/c7p8w/

Jak*_*ake 5

很难回答,因为你的小提琴没有显示问题。您应该能够通过为两个跨度vertical-align设置相同的设置来解决该问题。尝试给他们两个vertical-align:top;

编辑:啊,我在 IE 中看到了这个问题。

在这里工作小提琴:http : //jsfiddle.net/c7p8w/1/