0

这个重置样式表正确吗?我遇到的问题是 oi 和 ul。

如您所见,在下方

 ol li, ul li {
    margin: 5px 0 0 40px;
   }

我只想将它应用于页面内的列表,它有效,但是它也将样式应用于导航列表!在标题中,我怎样才能防止这种情况发生?

html, body, div, section, article, span, figure, figcaption, img, 
h1, h2, h3, h4, h5, h6, p, a, blockquote, pre, abbr, address, 
small, strong, sub, sup, input, output, textarea, ol, ul, li, fieldset, 
form, label, legend, tr, th, td, table, caption, footer, header, 
hgroup, aside, menu, nav, time, mark, audio, video, 
canvas, embed, iframe, object {

    margin: 0;
    padding: 0;
    border: none;
    font: inherit;
    max-width: 100%;
    text-decoration: none;
    box-sizing: border-box;
    -moz-box-sizing: border-box;    
    -webkit-box-sizing: border-box;
}

a {
    display: inline-block;
    -webkit-tap-highlight-color: rgba(0,0,0,0);
}

ol li, ul li {
    margin: 5px 0 0 40px;
}

abbr {
    font-weight: bold;
}

table {
    border-collapse: collapse;
    border-spacing: 0;
}

.hidden {
    display: none;
}
4

2 回答 2

0

只需创建一个更具体的类来覆盖它,例如

ul.yourNavClass li {
   margin: 0px 5px;
}

假设该类位于 ul 元素上,因为我看不到您的代码。如果不是,只需将其更改为任何布局方式.yourNavClass ul linav ul li等等。

于 2013-10-24T11:59:19.800 回答
0

如果您的元素中有li元素,您nav必须再次重置它们,或者(更好的方法)您应该指定哪些li元素应该具有这些边距。所以为他们使用一个类。

 ol li.margined, ul li.margined {
    margin: 5px 0 0 40px;
 }

或第一个选项

ol li, ul li {
    margin: 5px 0 0 40px;
}
nav ol li, nav ul li {
    margin: 0;
}
于 2013-10-24T11:59:38.433 回答