[英]Text-decoration: underline not applying with inline-block span elements
I'm having an issue with text-decoration: underline
on two spans that use inline-block
. 我遇到了
text-decoration: underline
的问题text-decoration: underline
使用inline-block
两个跨度text-decoration: underline
。 The [problem is only one part of the URL will underline when hovered, the other does not. [问题是,只有URL的一部分会在悬停时加下划线,另一部分不会。 I need to keep the display property, otherwise
text-overflow
won't get applied (see: Text-overflow: ellipsis alignment issue ) 我需要保留display属性,否则不会应用
text-overflow
(参见: Text-overflow:省略号对齐问题 )
HTML: 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>
</div>
CSS: 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;
vertical-align:top;
}
a:hover{
text-decoration:underline;
color:red;
}
jsFiddle: http://jsfiddle.net/c7p8w/2/ jsFiddle: http : //jsfiddle.net/c7p8w/2/
By CSS specs , the underline does not affect inline blocks inside the element for which text-decoration: underline
has been set. 根据CSS规范 ,下划线不会影响元素内部的内联块,
text-decoration: underline
已设置text-decoration: underline
。
You can make them underlined by explicitly setting that for them, for example by replacing the selector a:hover
in your last CSS rule by the selector list a:hover, a:hover *
. 你可以让他们通过更换选择明确设置,对于它们,例如强调
a:hover
在选择列表中你最后的CSS规则a:hover, a:hover *
。
This will not affect the ellipsis symbol, though. 但这不会影响省略号符号。 It is not part of any element content but inserted by a browser, so I don't think you can underline it.
它不是任何元素内容的一部分,而是由浏览器插入,所以我认为你不能强调它。
a little bit weird though... 虽然有点奇怪......
add these css? 添加这些CSS?
.details h2{
border-bottom:1px solid #fff; /*use the same color as your .details background color*/
}
.details h2:hover {
border-bottom:1px solid #f00;
}
See DEMO on jsfiddel... http://jsfiddle.net/c7p8w/14/ 请参阅jsfiddel上的DEMO ... http://jsfiddle.net/c7p8w/14/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.