2011-03-23 50 views
1

我一直在考虑一些HTML看起来像这样的(我有过HTML无法控制):打击标签问题与IE /铬

<p>Some text</p> 
<strike> 
    <p>This is some text</p> 
</strike> 
<p>More text</p> 

文本显示在IE和Chrome的三振出局,但不是在Firefox中。我已将display:inline-block添加到<p>标记,该标记修复了Firefox,但随后破坏了IE和Chrome。

是否有解决方案,这将在所有三个浏览器工作,不涉及更改HTML?

回答

3

我相信你的问题是由于一个嵌套元素inline<strike>)的内部block元素(<p>)。

这个CSS得到line-through嵌套<p>工作:

strike p { /* only applies to <p> tags that are children of a <strike> tag */ 
    padding: 0;      // remove default spacing from <p> tag 
    text-decoration: line-through; // fixes missing line-through 
} 

注:只有在Firefox 3.6.x的

+0

+1为解决原因。 “罢工”似乎在FF自己正常工作。 – Sapph 2011-03-23 17:33:20

+0

谢谢!有时候我只需要一个大笨蛋:) – Wavel 2011-03-23 17:41:35

-1

该标签没有得到普遍支持。使用下面的CSS

.strikethrough { text-decoration: line-through;} 

,然后相应地改变你的HTML

<p class="strikethrough">This is some text</p> 
+1

我有过HTML无法控制,所以我不能添加这些段落标签的类。我想我可以做一个风格虽然...... – Wavel 2011-03-23 17:29:31

2

使用CSS测试。

根据您的具体HTML例如:

strike p 
{ 
text-decoration: line-through; 
} 

的jsfiddle(验证了IE9,Chrome浏览器10,FF4工作):http://jsfiddle.net/hcYVv/1/

+0

+1用于验证其他浏览器 – drudge 2011-03-23 17:35:35