什么是默认列表样式(CSS)?

Ata*_*adj 84 html css html-lists

在我的网站上,我使用reset.css.它将这个添加到列表样式:

ol, ul {
    list-style: none outside none;
}
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td {
    background: none repeat scroll 0 0 transparent;
    border: 0 none;
    font-size: 100%;
    margin: 0;
    outline: 0 none;
    padding: 0;
    vertical-align: baseline;
}
Run Code Online (Sandbox Code Playgroud)

问题是所有列表样式都设置为NONEthis.我想为网站子页面上的所有列表(所有列表中.my_container)恢复原始列表样式(默认).

当我尝试设置时list-style-type,inherit不会为此CSS属性继承浏览器的默认样式.

有没有办法在不修改reset.css的情况下为某些属性继承原始浏览器的样式?

zes*_*ssx 135

我曾经设置这个CSS来删除重置:

ul { 
   list-style-type: disc; 
   list-style-position: inside; 
}
ol { 
   list-style-type: decimal; 
   list-style-position: inside; 
}
ul ul, ol ul { 
   list-style-type: circle; 
   list-style-position: inside; 
   margin-left: 15px; 
}
ol ol, ul ol { 
   list-style-type: lower-latin; 
   list-style-position: inside; 
   margin-left: 15px; 
}
Run Code Online (Sandbox Code Playgroud)

编辑:具体课程......

  • 它不会"恢复原始列表样式(默认)".它只是设置*一些*样式. (5认同)
  • list-style-type没有"默认"选项,我在得到答案后发现了.浏览器只是添加了一些浏览器之间通常不一致的样式. (2认同)

Col*_*old 31

我认为这实际上是你正在寻找的:

.my_container ul
{
    list-style: initial;
    margin: initial;
    padding: 0 0 0 40px;
}

.my_container li
{
    display: list-item;
}
Run Code Online (Sandbox Code Playgroud)

  • 任何版本的IE都不支持`initial` http://msdn.microsoft.com/en-us/library/hh781508%28v=vs.85%29.aspx#keywords (8认同)

Rez*_*mun 10

按照文档,大多数浏览器将显示<ul>,<ol><li>使用以下默认值的元素:

ULOL标记的默认CSS设置:

ul, ol { 
    display: block;
    list-style: disc outside none;
    margin: 1em 0;
    padding: 0 0 0 40px;
}
ol { 
    list-style-type: decimal;
}
Run Code Online (Sandbox Code Playgroud)

LI标签的默认CSS设置:

li { 
    display: list-item;
}
Run Code Online (Sandbox Code Playgroud)

样式嵌套列表项:

ul ul, ol ul {
    list-style-type: circle;
    margin-left: 15px; 
}
ol ol, ul ol { 
    list-style-type: lower-latin;
    margin-left: 15px; 
}
Run Code Online (Sandbox Code Playgroud)

注意:如果我们将上述样式与类一起使用,结果将是完美的.另请参阅不同的List-Item标记.


jer*_*iuh 9

http://www.w3schools.com/tags/tag_ul.asp

ul { 
    display: block;
    list-style-type: disc;
    margin-top: 1em;
    margin-bottom: 1em;
    margin-left: 0;
    margin-right: 0;
    padding-left: 40px;
}
Run Code Online (Sandbox Code Playgroud)