我有一个包含 2 个 div 的页面,并添加了重置 css 以删除最初添加到该页面的所有浏览器默认值。 在第二个 div 中,我有某些使用浏览器填充的 Ul 和 li。问题是我不希望重置 css 继承到第二个 div。第二个 div 剩余元素不应使用重置 css 重置。你能告诉我如何防止重置 css 被继承到第二个 div 吗?谢谢!!!
<style>
html, body, div, span, applet, object, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a,
abbr,acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small,
strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, fieldset, form, label,
legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details,
embed, figure,ul,li,ol,figcaption, footer, header, hgroup, menu, nav, output, ruby,
section, summary, time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
</style>
<div>
<ul><li>Reset CSs should be inherited</li></ul>
</div>
<div>
<ul>
<li>Default browser padding to be added without reset css</li>
</ul>
</div>
最佳答案
像这样使用类
,
CSS
.reset-css{
/** properties for reset */
}
HTML
<div class="reset-css">
<ul><li>Reset CSs should be inherited</li></ul>
</div>
关于javascript - 如何不将重置的 css 文件继承到特定的 div?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22829025/