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

时间:2013-05-29 02:11:52

标签: html css truncate rich-snippets css3

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

enter image description here

问题是我无法将跨度排列在一起。通过修改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>

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;
}

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

1 个答案:

答案 0 :(得分:3)

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

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

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

相关问题