float浮動練習

HTML 代碼

 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>float浮動</title>
    <link rel="stylesheet" href="../css/float.css">
</head>
<body>
    <div id="main">
        <h2 class="title">外媒評論精選</h2>
        <ul>
            <li class="clear">
                <div class="l pic">
                    <a href="">
                        <img src="../images/pic1.png" alt="">
                    </a>
                </div>
                <div class="l content">
                    <h2>《加勒比海盜》-- 商業味濃郁</h2>
                    <p>
                        本集《加勒比海盜》講述了傑克船長受英王所託尋找 「不老泉」,與他. . . 
                        <a href="#">[詳細]</a>
                    </p>
                </div>
            </li>
            <li class="clear">
                <div class="l pic">
                    <a href="">
                        <img src="../images/pic2.png" alt="">
                    </a>
                </div>
                <div class="l content">
                    <h2>《雷神托爾》-- 神話版莎翁戲劇</h2>
                    <p>
                        《雷神》 由克里斯.海姆斯活斯和今年新晉奧斯卡影后娜塔.波特曼...
                        <a href="#">[詳細]</a>
                    </p>
                </div>
            </li>
            <li class="clear">
                <div class="l pic">
                    <a href="">
                        <img src="../images/pic3.png" alt="">
                    </a>
                </div>
                <div class="l content">
                    <h2>《源代碼》-- 科幻與驚悚完美結合</h2>
                    <p>
                        《源代碼》由傑克.吉倫哈爾、米歇爾.莫娜漢、維拉.法梅加主演。...
                        <a href="#">[詳細]</a>
                    </p>
                </div>
            </li>
           
        </ul>
    </div>
</body>
</html>

 

CSS 代碼

*{margin: 0;padding: 0;}
ul{ list-style: none;}
a{text-decoration: none;color:#666;}
img{display: block;}
h1,h2,h3{font-size:16px;}

.l{float: left;}
.r{float: right;}
.clear:after{content: "";display: block;clear: both;}

#main{width:486px;margin: 100px auto;border:1px solid #626667;}
#main>.title{
    height: 30px;background:url(../images/bgtitle.png)no-repeat 7px 7px,url(../images/bgline.png)repeat-x;
    padding-left: 40px;line-height: 30px;font-size:14px;color:#30444b;
}
#main ul{margin-top: 18px;}
#main .pic{width: 132px;border:1px solid #dbdfe2;}
#main .pic img{margin: 3px;}
#main .content{width: 330px;font-size: 14px;margin-left: 12px;}
#main .content h2{height:32px;line-height:30px;color:#202123;font-size: 14px;padding-left:26px;}
#main .content p{line-height: 26px;color:#626667;}
#main .clear{margin-left: 7px;margin-bottom: 30px;}
#main li.clear:last-of-type{margin-bottom: 13px;}

效果圖

相關文章
相關標籤/搜索