默认将父样式应用于内部子DOM元素

时间:2014-02-17 07:21:11

标签: asp.net css html5 dom

如何让段内的内部跨度继承段落中定义的样式?

<p class='NavnAdr2 Normal' style='line-height: 12pt; margin-top: 0pt; margin-bottom: 0pt;
                        font-family: Times New Roman;'>
                        <span>Sample test</span></p>

2 个答案:

答案 0 :(得分:2)

只需为每个Css属性设置继承。

<span style="line-height: inherit; margin-top: inherit; margin-bottom: inherit;  font-family: inherit;">Sample test</span>

答案 1 :(得分:1)

不要编写内联样式,而是尝试将样式应用于p标记&amp;其下的所有span标记为:

.NavnAdr2, .NavnAdr2 span {
  line-height: 12pt; 
  margin-top: 0pt; 
  margin-bottom: 0pt;
  font-family: Times New Roman;
}
相关问题