admin管理员组文章数量:1287507
I have a code where if I apply text-decoration: line-through; on outer div, all the inner div elements also must be 'strikethroughed'. This works 100% fine normally; But, if I put the child elements as 'display:inline-block', now the strikethrough applied to the parent div does not effect the strikeness to the childs. I have to put the childs as display:inline-block and I need the childs to be crossed out at the addition of text-decoration: line-through; to the parent div.
div{padding:10px;}
#outer{background:yellow;text-decoration: line-through;}
#inner{background:pink;display:inline-block;}
<div id=outer>
<div id=inner>
This is the text
</div>
</div>
I have a code where if I apply text-decoration: line-through; on outer div, all the inner div elements also must be 'strikethroughed'. This works 100% fine normally; But, if I put the child elements as 'display:inline-block', now the strikethrough applied to the parent div does not effect the strikeness to the childs. I have to put the childs as display:inline-block and I need the childs to be crossed out at the addition of text-decoration: line-through; to the parent div.
div{padding:10px;}
#outer{background:yellow;text-decoration: line-through;}
#inner{background:pink;display:inline-block;}
<div id=outer>
<div id=inner>
This is the text
</div>
</div>
This is an office project, and your help is appreciated !
Share Improve this question edited May 29, 2015 at 8:09 CodingIntrigue 78.6k32 gold badges175 silver badges177 bronze badges asked May 29, 2015 at 8:05 DeadpoolDeadpool 8,2409 gold badges48 silver badges95 bronze badges 3-
1
you missed
"
quotes aroundid
. likeid="outer"
– Amit Soni Commented May 29, 2015 at 8:10 - 2 It wont effect bro. That's not the problem. Results would be same ... – Deadpool Commented May 29, 2015 at 8:11
- 1 @AmitSoni Not required in HTML5. – CodingIntrigue Commented May 29, 2015 at 8:12
2 Answers
Reset to default 9Use text-decoration:inherit
.
div{padding:10px;}
#outer{background:yellow;text-decoration: line-through;}
#inner{background:pink;display:inline-block; text-decoration:inherit}
<div id=outer>
<div id=inner>
This is the text
</div>
</div>
Normally, text-decoration
is not an inherited property, so the inner div has an implicit text-decoration:none
, the default. By using inherit
, you tell the element that it should have the same text decoration as its parent.
The default value for text-decoration
is none
, so you need to specify a value if you want it to be different. Use inherit
to use the parent's value:
#outer > div { text-decoration: inherit; }
or adapt the css for #inner
to include text-decoration: inherit;
:
#inner { background: pink; display: inline-block; text-decoration: inherit; }
Example
div{padding:10px;}
#outer{background:yellow;text-decoration: line-through;}
#inner{background:pink;display:inline-block; text-decoration: inherit; }
<div id=outer>
<div id=inner>
This is the text
</div>
</div>
本文标签: javascriptCSSAmazingly strikethrough not working on child displayinlineblock divStack Overflow
版权声明:本文标题:javascript - CSS : Amazingly strikethrough not working on child display:inline-block div - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741288068a2370387.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论