問題描述
在我的網站上,我使用了 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;
}
問題是所有列表樣式都設定為 NONE
。我想恢復原始列表樣式 (預設),僅適用於網站 sub-pages 上的所有列表 (.my_container
中的所有列表) 。
當我嘗試設定 list-style-type
到 inherit
的設定是不繼承瀏覽器的預設樣式只為這個 CSS 屬性。
有沒有辦法繼承原始瀏覽器的樣式的某些屬性,而不修改 reset.css?
最佳解決方案
我曾經設定這個 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;
}
編輯:當然有一個特定的課程…
次佳解決方案
我認為這其實是你要找的:
.my_container ul
{
list-style: initial;
margin: initial;
padding: 0 0 0 40px;
}
.my_container li
{
display: list-item;
}
第三種解決方案
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;
}
第四種方案
你不能。每當應用任何樣式表分配屬性到元素時,沒有辦法得到瀏覽器預設值,對於元素的任何例項。
reset.css 的 (有爭議的) 想法是擺脫瀏覽器預設設定,以便您可以從乾淨的桌面開始自己的樣式。沒有版本的 reset.css 完全完成,但是在他們做的程度上,使用 reset.css 的作者應該完全定義渲染。
參考文獻
注:本文內容整合自 Google/Baidu/Bing 輔助翻譯的英文資料結果。如果您對結果不滿意,可以加入我們改善翻譯效果:薇曉朵技術論壇。