1.列表
1.在 HTML 中,有两种类型的列表:
①无序列表 ul
:列表项标记用特殊图形(如小黑点、小方框等)。
②有序列表 ol
:列表项的标记有数字或字母。
2.不同的列表项标记
1.list-style-type
属性指定列表项标记的类型。
<style>
ul.a {list-style-type:circle;}
ul.b {list-style-type:square;}
ol.c {list-style-type:upper-roman;}
ol.d {list-style-type:lower-alpha;}
</style>
3.列表项标记的图像
1.list-style-image
:指定列表项标记的图像,使用列表样式图像属性。
ul
{
list-style-image: url('sqpurple.gif');
}
2.浏览器兼容性解决方案。
ul
{
list-style-type: none;
padding: 0px;
margin: 0px;
}
ul li
{
background-image: url(sqpurple.gif);
background-repeat: no-repeat;
background-position: 0px 5px;
padding-left: 14px;
}
3.例子解释:
①ul
:
设置列表类型为没有列表项标记。
设置填充和边距 0px(浏览器兼容性)。
②ul
中所有 li
:
设置图像的 URL,并设置它只显示一次(无重复)。
您需要的定位图像位置(左 0px 和上下 5px)。
用 padding-left
属性把文本置于列表中。
4.简写属性
1.在单个属性中可以指定所有的列表属性。这就是所谓的简写属性。(list-style
)
ul
{
list-style: square url("sqpurple.gif");
}
2.可以按顺序设置如下属性:
①list-style-type
。
②list-style-position
。
③list-style-image
。
如果上述值丢失一个,其余仍在指定的顺序,就没关系。
3.更多实例:
<style>
ul.a {list-style-type:circle;}
ul.b {list-style-type:disc;}
ul.c {list-style-type:square;}
ol.d {list-style-type:armenian;}
ol.e {list-style-type:cjk-ideographic;}
ol.f {list-style-type:decimal;}
ol.g {list-style-type:decimal-leading-zero;}
ol.h {list-style-type:georgian;}
ol.i {list-style-type:hebrew;}
ol.j {list-style-type:hiragana;}
ol.k {list-style-type:hiragana-iroha;}
ol.l {list-style-type:katakana;}
ol.m {list-style-type:katakana-iroha;}
ol.n {list-style-type:lower-alpha;}
ol.o {list-style-type:lower-greek;}
ol.p {list-style-type:lower-latin;}
ol.q {list-style-type:lower-roman;}
ol.r {list-style-type:upper-alpha;}
ol.s {list-style-type:upper-latin;}
ol.t {list-style-type:upper-roman;}
ol.u {list-style-type:none;}
ol.v {list-style-type:inherit;}
</style>
5.移除默认设置
1.list-style-type:none
属性可以用于移除小标记。默认情况下列表 <ul>
或 <ol>
还设置了内边距和外边距,可使用 margin:0
和 padding:0
来移除:
ul.demo {
list-style-type: none;
margin: 0;
padding: 0;
}
6.list-style-position
属性
<style type="text/css">
ul.inside
{
list-style-position: inside
}
ul.outside
{
list-style-position: outside
}
</style>