list-style 列表项目标记样式解决方案

list-style 简写属性在一个声明中设置所有的列表属性。

可以按顺序设置如下属性:
       •list-style-type
       •list-style-position
       •list-style-image

默认值: disc outside none

 

/*reset*/

list-style:none outside none;  

 

效果图1:

关键代码:

background:url(images/web01a_05.png) no-repeat;
text-indent:40px;  /*首行文字缩进*/
line-height:2em;
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>list-style</title>
<style type="text/css">
    *{margin: 0;padding:0;}
    .clearfix:after,.clearfix:before{display:table;content:""}
    .clearfix:after{clear:both;overflow:hidden}
    ul{ width:300px; margin:20px auto 0;}
    li{ 
        list-style:none outside none;  /*reset*/
        background:url(images/web01a_05.png) no-repeat;
        text-indent:40px;
        line-height:2em;
        border:1px solid #CCC;
        margin-bottom:10px;
    }
</style>
</head>

<body>
    <ul>
        <li>inside 列表项目标记放置在文本以内,且环绕文本根据标记对齐。</li>
        <li>outside 默认值。保持标记位于文本的左侧。列表项目标记放置在文本以外,且环绕文本不根据标记对齐。</li>
        <li>inherit 规定应该从父元素继承 list-style-position 属性的值。</li>
    </ul>
</body>
</html>

 

效果图2:

 

关键代码:

background:url(images/web01a_05.png) no-repeat;
padding-left:40px;

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>list-style</title>
<style type="text/css">
    *{margin: 0;padding:0;}
    .clearfix:after,.clearfix:before{display:table;content:""}
    .clearfix:after{clear:both;overflow:hidden}
    ul{ width:300px; margin:20px auto 0;}
    li{ 
        list-style:none outside none;  /*reset*/
        background:url(images/web01a_05.png) no-repeat;
        line-height:2em;
        padding-left:40px;
        border:1px solid #CCC;
        margin-bottom:10px;
    }
</style>
</head>

<body>
    <ul>
        <li>inside 列表项目标记放置在文本以内,且环绕文本根据标记对齐。</li>
        <li>outside 默认值。保持标记位于文本的左侧。列表项目标记放置在文本以外,且环绕文本不根据标记对齐。</li>
        <li>inherit 规定应该从父元素继承 list-style-position 属性的值。</li>
    </ul>
</body>
</html>

 

效果图3:

关键代码:

background:url(images/web01a_05.png) no-repeat left center;  /*定位背景图标位置*/
padding-left:40px;
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>list-style</title>
<style type="text/css">
    *{margin: 0;padding:0;}
    .clearfix:after,.clearfix:before{display:table;content:""}
    .clearfix:after{clear:both;overflow:hidden}
    ul{ width:300px; margin:20px auto 0;}
    li{ 
        list-style:none outside none;  /*reset*/
        background:url(images/web01a_05.png) no-repeat left center;
        line-height:2em;
        padding-left:40px;
        border:1px solid #CCC;
        margin-bottom:10px;
    }
</style>
</head>

<body>
    <ul>
        <li>inside 列表项目标记放置在文本以内,且环绕文本根据标记对齐。</li>
        <li>outside 默认值。保持标记位于文本的左侧。列表项目标记放置在文本以外,且环绕文本不根据标记对齐。</li>
        <li>inherit 规定应该从父元素继承 list-style-position 属性的值。</li>
    </ul>
</body>
</html>

 

转载于:https://www.cnblogs.com/linyongqin/articles/3993950.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值