
Paste_Image.png
    <style type="text/css">
        body,#container,#header,#content,ul{
            padding: 0px;
            margin: 0px;
        }
        
        #container{
            width: 800px;
            margin: 0px auto;
        }
        
        #header{
            width: 100%;
        }
        
        #content{
            width: 100%;
        }
        
        #list{
            width: 600px;
            margin: 0px auto;/*水平居中*/
            border-left: 3px;
            border-left-style: solid;
            border-left-color: #CCCCCC;
            
        }       
        
        #list ul li{
            
            list-style: none;/*去掉列表的小点*/
            width: 100%;
            height: 30px;
            line-height: 30px;
            border-bottom: 1px dashed #ccc;
            font-family: cursive;
            font-size: 16px;
            margin-bottom: 50px;
            border-bottom-style: dashed;
        }
        
        /*前面的小圆点*/
        #list ul li span{
            display: block;    /*只有先设置为块级元素才能设置其宽高*/
            float: left;
            width: 6px;
            height: 6px;
            background-color:coral;
            border-radius: 50%;
            position: relative;
            left: -5px;
            top: 12px;
        }
        
        
        #list ul li p{
            margin-left: 20px;
            font-size: 14px;
            color: bisque;
            font-family: serif;
        }
        
        #list ul li a {
            text-decoration: none;    /*去掉a标签下划线*/
            color: #666;
            font-family: serif;
        }
        
        #list ul li a:hover{
            color: coral;
        }
        
        #list ul li p b {
            margin-left: 10px;/*文字和时间的间隔*/
            font-family: serif;
        }
        
        #header #title{
            width: 400px;
            height: 200px;
            margin: 0px auto;
            margin-top: 40px;
            text-align: center;
        }
        
        #title p{
            width: 200px;
            height: 40px;
            background-color: black;
            margin: 0px auto;
            line-height: 40px;
            margin-top: 60px;
            font-size: 25px;
            color: white;
        }
        
        #title .subTitle{
            display: block;
            color: coral;
            font-size: 20px;
            margin-top: 40px;
        }
    </style>
</head>
<body>
    <div id="container">
        
        <div id="header"> 
            <div id="title"> 
                <p>丁丁服务中心</p>
                <i class="subTitle">一家专做特“卖”的网站</i><!--用一个空格来充当该div的第一个元素,这样后面的子元素设置margin时就不会影响到其位置-->
            </div>
        </div>
            
        <div id="content">
            <div id="list"> 
                <ul>
                    <li><span></span><p><a href="">08-19 来啦</a></p></li>
                    <li><span></span><p><a href="">08-19 来啦</a></p></li>
                    <li><span></span><p><a href="">08-19 来啦</a></p></li>
                    <li><span></span><p><a href="">08-19 来啦</a></p></li>
                    <li><span></span><p><a href="">08-19 来啦</a></p></li>
                    <li><span></span><p><a href="">08-19 来啦</a></p></li>
                </ul>
            </div>
        </div>
    </div>
</body>
总结:#####
垂直margin在盒模型中被折叠的问题:
“collapsing margins”(折叠margin)的意思是:2个或2个以上盒模型之间(关系可以是相邻或嵌套)相邻的margin属性(这之间不能有非空内容、padding区域、border边框或使用清除分离方法)结合表示为一个单独的margin;
因为折叠margin的问题,我们在设置盒子的margin时,可能会直接影响到其父盒子,所以我们可以根据其特性来打破这种折叠margin,方法有如下几种:
- 在两个盒子之间加入非空内容(如: )
- 加入padding(如:padding-top: 1px)
- 设置border(如:border: 1px solid #000)
- 清除分离方法(不会)
一个盒子要想在其父盒子中水平垂直居中:
- 设置margin:0px auto(上下为0,水平自动);
- 设置margin-top:xxpx;

Paste_Image.png
一个文本在盒子(p也算盒子)中水平垂直居中:
- 设置盒子text-align:center;
- 设置盒子line-height:父盒子高度

Paste_Image.png