drupal中定制ul list-style

难易程度: 中到高级.

 

例1:基本

在这个例子中,我们将创建一个无序列表(ul),它将在特定区域展示一个光盘,跟着是一列项目,而在网站的其它部分将会隐藏这些信息.接着你可以决定,在你的网站中,你要为哪些列表添加样式.

 

注意:

注意,你一定要在测试站点进行试验,而对于要用到的文件要有备份.

我们将使用一个div,它的名字为"content".你的div的名称可能有所不同.在div中,我们放置ul列表,我们将对其添加样式:

 

<div id="content">
<ul class="unordered_list_in_content">
<li>list item 1</li>
<li>list item 2</li>
<li>list item 3</li>
</ul>
</div>

 

在你的样式表中你将使用:

 

ul { list-style-type:none } /* This will turn off all list-style-types in your theme */
#content ul.unordened_list_in_content { list-style-type: disc }

 

现在,你应该可以在你选择的区域看到带有光盘的列表,而不是在网站的其它部分.

 

例2:让我们添加一些有趣的列表样式

在一个主题中关闭所有的list-style,使用:

ul {list-style:none}

代替

ul {list-style-type:none}

 

你可以这样:

ul {list-style:disc inside}

代替

ul {list-style-type:disc}

 

这样你最终的样式表将会是:

 

ul {list-style:none}
#content ul.unordered_list_in_content { list-style: disc inside}

 

 

注意:如果在你的主题中,有多个样式的话,你需要确保没有list-styles来覆写你的CSS,否则它还是显示不出来.

 

注意: list-style-type已被禁用,更多细节参看http://www.w3.org/TR/html401/struct/lists.html.

 

提示:这也适用于节点内部的ul,比如一个page 或者story.

 

原文:http://drupal.org/node/263979

译者:葛红儒, Think in Drupal

 

Drupal版本: