2016/4/17 去除 ul ol 前标记 list-style:none list-style-type:none

对于很多人用div来做网站时,总会用到,但在显示效果时前面总是会有一个小黑点,这个令很多人头痛,但又找不到要源,其它我们可以用以下方法来清除。

1、在CSS中写入代码。找到相关性的CSS,在。.li和.ul下写入list-sytle:none;当然有的会这样来写list-style-type:none, 这种写法特别是在一些CMS中最常见。

2、在相关的页面找到head部分写入下面的代码

<style type="text/css">

list-style:none;

</style>

3、在li,ul内加入list-style。如<ul style="list-style-type:none><li><a herf="http://blog.csdn.net/business122">我的博客</a></li>< /ul> 当然这种是很麻烦的了。

最简单的就是第一种了,通过CSS来控制,这个当然会有不错的效果了。

这几种方法都是通过设置list-style:none来设置的,有的是会用list-style-type,下面我们来看一看它的属性.

none不使用项目符号

disc实心圆,默认值

circle空心圆

square实心方块

decimal阿拉伯数字

lower-roman小写罗马数字

upper-roman大写罗马数字

lower-alpha小写英文字母

upper-alpha大写英文字母

这些都可以来代替上文中的none,想要什么样的都会有一个相应的对应。

A).运用CSS格式化列表符: ul li{

list-style-type:none;

}

B).如果你想将列表符换成图像,则: ul li{

list-style-type:none;

list-style-image: url(images/icon.gif);

}

C).为了左对齐,可以用如下代码: ul{

list-style-type:none;

margin:0px;

}

D).如果想给列表加背景色,可以用如下代码: ul{

list-style-type: none;

margin:0px;

}

ul li{

background:#CCC;

}

E).如果想给列表加MOUSEOVER背景变色效果,可以用如下代码: ul{ list-style-type: none; margin:0px; }

ul li a{ display:block; width: 100%; background:#ccc; }

ul li a:hover{ background:#999; }说明:display:block;这一行必须要加的,这样才能块状显示!

F).LI中的元素水平排列,关键FLOAT:LEFT: ul{

list-style-type:none;

width:100%;

}

<li class="alt"><span><span>对于很多人用div来做网站时,总会用到,但在显示效果时前面总是会有一个小黑点,这个令很多人头痛,但又找不到要源,其它我们可以用以下方法来清除。&nbsp;&nbsp;</span></span></li><li class=""><span><span class="value">1</span><span>、在CSS中写入代码。找到相关性的CSS,在。.li和.ul下写入list-sytle:</span><span class="value">none</span><span>;当然有的会这样来写</span><span class="keyword">list-style-type</span><span>:</span><span class="value">none</span><span>,&nbsp;这种写法特别是在一些CMS中最常见。&nbsp;&nbsp;</span></span></li><li class="alt"><span><span class="value">2</span><span>、在相关的页面找到head部分写入下面的代码&nbsp;&nbsp;</span></span></li><li class=""><span><style&nbsp;type=<span class="string">"text/css"</span><span>>&nbsp;&nbsp;</span></span></li><li class="alt"><span><span class="keyword">list-style</span><span>:</span><span class="value">none</span><span>;&nbsp;&nbsp;</span></span></li><li class=""><span></style>&nbsp;&nbsp;</span></li><li class="alt"><span><span class="value">3</span><span>、在li,ul内加入list-style。如<ul&nbsp;style=</span><span class="string">"list-style-type:none><li><a&nbsp;herf="</span><span>http://blog.csdn.net/business</span><span class="value">122</span><span>">我的博客</a></li><&nbsp;/ul>&nbsp;当然这种是很麻烦的了。&nbsp;&nbsp;</span></span></li><li class=""><span>最简单的就是第一种了,通过CSS来控制,这个当然会有不错的效果了。&nbsp;&nbsp;</span></li><li class="alt"><span>这几种方法都是通过设置<span class="keyword">list-style</span><span>:</span><span class="value">none</span><span>来设置的,有的是会用list-style-type,下面我们来看一看它的属性.&nbsp;&nbsp;</span></span></li><li class=""><span><span class="value">none</span><span>不使用项目符号&nbsp;&nbsp;</span></span></li><li class="alt"><span><span class="value">disc</span><span>实心圆,默认值&nbsp;&nbsp;</span></span></li><li class=""><span><span class="value">circle</span><span>空心圆&nbsp;&nbsp;</span></span></li><li class="alt"><span><span class="value">square</span><span>实心方块&nbsp;&nbsp;</span></span></li><li class=""><span><span class="value">decimal</span><span>阿拉伯数字&nbsp;&nbsp;</span></span></li><li class="alt"><span><span class="value">lower-roman</span><span>小写罗马数字&nbsp;&nbsp;</span></span></li><li class=""><span><span class="value">upper-roman</span><span>大写罗马数字&nbsp;&nbsp;</span></span></li><li class="alt"><span><span class="value">lower-alpha</span><span>小写英文字母&nbsp;&nbsp;</span></span></li><li class=""><span><span class="value">upper-alpha</span><span>大写英文字母&nbsp;&nbsp;</span></span></li><li class="alt"><span>这些都可以来代替上文中的<span class="value">none</span><span>,想要什么样的都会有一个相应的对应。&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;</span></li><li class="alt"><span>&nbsp;A).运用CSS格式化列表符:&nbsp;ul&nbsp;li{&nbsp;&nbsp;</span></li><li class=""><span><span class="keyword">list-style-type</span><span>:</span><span class="value">none</span><span>;&nbsp;&nbsp;</span></span></li><li class="alt"><span>}&nbsp;&nbsp;</span></li><li class=""><span>B).如果你想将列表符换成图像,则:&nbsp;ul&nbsp;li{&nbsp;&nbsp;</span></li><li class="alt"><span><span class="keyword">list-style-type</span><span>:</span><span class="value">none</span><span>;&nbsp;&nbsp;</span></span></li><li class=""><span><span class="keyword">list-style-image</span><span>:&nbsp;</span><span class="value">url</span><span>(images/</span><span class="value">icon</span><span>.gif);&nbsp;&nbsp;</span></span></li><li class="alt"><span>}&nbsp;&nbsp;</span></li><li class=""><span>C).为了左对齐,可以用如下代码:&nbsp;ul{&nbsp;&nbsp;</span></li><li class="alt"><span><span class="keyword">list-style-type</span><span>:</span><span class="value">none</span><span>;&nbsp;&nbsp;</span></span></li><li class=""><span><span class="keyword">margin</span><span>:</span><span class="value">0px</span><span>;&nbsp;&nbsp;</span></span></li><li class="alt"><span>}&nbsp;&nbsp;</span></li><li class=""><span>D).如果想给列表加背景色,可以用如下代码:&nbsp;ul{&nbsp;&nbsp;</span></li><li class="alt"><span><span class="keyword">list-style-type</span><span>:&nbsp;</span><span class="value">none</span><span>;&nbsp;&nbsp;</span></span></li><li class=""><span><span class="keyword">margin</span><span>:</span><span class="value">0px</span><span>;&nbsp;&nbsp;</span></span></li><li class="alt"><span>}&nbsp;&nbsp;</span></li><li class=""><span>ul&nbsp;li{&nbsp;&nbsp;</span></li><li class="alt"><span><span class="keyword">background</span><span>:</span><span class="value">#CCC</span><span>;&nbsp;&nbsp;</span></span></li><li class=""><span>}&nbsp;&nbsp;</span></li><li class="alt"><span>E).如果想给列表加MOUSEOVER背景变色效果,可以用如下代码:&nbsp;ul{&nbsp;<span class="keyword">list-style-type</span><span>:&nbsp;</span><span class="value">none</span><span>;&nbsp;</span><span class="keyword">margin</span><span>:</span><span class="value">0px</span><span>;&nbsp;}&nbsp;&nbsp;</span></span></li><li class=""><span>ul&nbsp;li&nbsp;a{&nbsp;<span class="keyword">display</span><span>:</span><span class="value">block</span><span>;&nbsp;</span><span class="keyword">width</span><span>:&nbsp;</span><span class="value">100%</span><span>;&nbsp;</span><span class="keyword">background</span><span>:</span><span class="value">#ccc</span><span>;&nbsp;}&nbsp;&nbsp;</span></span></li><li class="alt"><span>ul&nbsp;li&nbsp;a:hover{&nbsp;<span class="keyword">background</span><span>:</span><span class="value">#999</span><span>;&nbsp;}说明:</span><span class="keyword">display</span><span>:</span><span class="value">block</span><span>;这一行必须要加的,这样才能块状显示!&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;</span></li><li class="alt"><span>F).LI中的元素水平排列,关键FLOAT:LEFT:&nbsp;ul{&nbsp;&nbsp;</span></li><li class=""><span><span class="keyword">list-style-type</span><span>:</span><span class="value">none</span><span>;&nbsp;&nbsp;</span></span></li><li class="alt"><span><span class="keyword">width</span><span>:</span><span class="value">100%</span><span>;&nbsp;&nbsp;</span></span></li><li class=""><span>}&nbsp;&nbsp;</span></li>

上一篇:面试常问MySQL性能优化问题


下一篇:DIV+CSS中标签ul ol li dl dt dd用法