css background实例

<!DOCTYPE html>  
<html>  
<head>  
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
    <title>background</title>  
    <style type="text/css">
        .my-style {
            width: 100%;
            height: 200px;
            background-image: url("http://www.runoob.com/try/demo_source/gradient2.png");
            background-repeat: repeat-x;
            border: 1px solid #ddd;
            margin-bottom: 5px;
        }
        .my-style2 {
            width: 100%;
            height: 400px;
            background-image: url("http://www.runoob.com/try/demo_source/img_tree.png");
            background-repeat: no-repeat;
            background-position: right top;
            border: 1px solid #ddd;
            margin-bottom: 5px;
        }
        .my-style3 {
            width: 100%;
            height: 400px;
            background: #8cd6f5 url("http://www.runoob.com/try/demo_source/img_tree.png") no-repeat center bottom;
            border: 1px solid #ddd;
            margin-bottom: 5px;
        }    
        .my-style4 {
            width: 100%;
            height: 400px;
            background: #8cf599 url("http://www.runoob.com/try/demo_source/img_tree.png") no-repeat center bottom;
            background-size: 100px 250px;
            background-position-y: 20px;
            border: 1px solid #ddd;
            margin-bottom: 5px;
        }              
    </style>
</head>  
<body>
    <div class="my-style"></div>
    <div class="my-style2"></div>
    <div class="my-style3"></div>
    <div class="my-style4"></div>
</body>  
</html>






posted @ 2017-11-24 18:06  徐同保  阅读(275)  评论(0编辑  收藏  举报