最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Python全棧之學(xué)習(xí)CSS(2)

 更新時間:2022年01月23日 16:59:53   作者:熬夜泡枸杞  
這篇文章主要為大家介紹了Python全棧之CSS,具有一定的參考價值,感興趣的小伙伴們可以參考一下,希望能夠給你帶來幫助

1. css背景圖

1.1 背景屬性

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>css 背景屬性</title>
    <style>
        .c1
        {
            /* 具體寫法 */
            width:600px;
            height:600px;
            border:solid 1px red;
            background-color: yellow;
            /* 控制背景圖 */
            background-image:url("./images/xiao.jpg");
            /* 控制是否平鋪 repeat-x  repeat-y  no-repeat  repeat(默認(rèn))*/
            background-repeat:no-repeat;
            /* 控制背景圖像的位置 ; 參數(shù)1 控制左右 參數(shù) 控制上下 */
            /* background-position:  50%  50%; */
            /* 固定背景圖使用 fixed 了解 */
            background-attachment: fixed;
        }
        .c2
        {
            /* 簡寫 */
            width:600px;
            height:600px;
            margin:10px 20px;
            border:solid 1px red;        
            /* 圖片 是否平鋪 [圖片位置] */
            background: url("./images/xiao.jpg") no-repeat 50% 50%;
        }
    </style>
</head>
<body>
    <div class="c1"></div>
    <div class="c2"></div>
</body>
</html>

請?zhí)砑訄D片描述

1.2 背景圖片引入

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>背景圖片的引入</title>
    <style>
        /* 鼠標(biāo)滑過,點亮圖片 */
        div.c1
        {width:60px;height:60px;border:solid 1px gray;background: url("./images/tag.jpg") no-repeat;}
        div.c1:hover
        {
            background: url("./images/tag.jpg") no-repeat;
            background-position: -312px -3.5px;
        }
        .gg
        {
            width:400px;
            height:400px;
            border:solid 1px red;
        }
        /* 一張圖片的導(dǎo)入 */
        div.c2
        {
            background: url("./images/xiao.jpg") no-repeat;
            /* 參數(shù)1:寬 參數(shù)2:高  50px 50px / 100% 100% */
            /* 控制背景圖像的尺寸大小 background-size: 100% 100% ; */
            background-size: 100% auto;
        }
        /* 多張圖片導(dǎo)入 */
        div.c3
        {
            background: 
                url("./images/game/map_19.gif") no-repeat 30px 80px,
                url("./images/game/map_20.gif") no-repeat 50px 50px,
                url("./images/game/map_18.gif") no-repeat 100px 50px,
                url("./images/game/map_14.gif") no-repeat 180px 100px,
                url("./images/game/map_03.gif");
        }
    </style>
</head>
<body>
    <div class="c1"></div>
    <div class="c2 gg"></div>
    <div class="c3 gg"></div>
</body>
</html>

請?zhí)砑訄D片描述

請?zhí)砑訄D片描述

請?zhí)砑訄D片描述

請?zhí)砑訄D片描述

請?zhí)砑訄D片描述

請?zhí)砑訄D片描述

2. 相對_絕對_固定

2.1 相對定位

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>定位:相對定位 relative</title>
    <style>
        .gg
        {
            width:200px;
            height:200px;
            border:solid 1px red;
        }
        .c1
        {background:violet;}
        .c2
        {
            background:tan;
            position:relative;
            top:10px;
            left:100px;
            z-index:2;
        }
        .c3
        {background:blue;}
        .c4
        {background:green;}
    </style>
</head>
<body>
        <!-- 
            相對定位: 參考點是他自己本身,相對于原始的位置進(jìn)行定位;
            如果添加了定位:無論是添加(相對,絕對,固定)屬性,添加之后會增加額外的其他屬性:
            z-index 控制層疊關(guān)系: 值越大越在上層,值越小越在下層
                left
                top
                right
                bottom 
                z-index
        
        -->
        <div class="c1 gg"></div>
        <div class="c2 gg"></div>
        <div class="c3 gg"></div>
        <div class="c4 gg"></div>
</body>
</html>

2.2 絕對定位

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>定位:絕對定位 absolute</title>
    <style>
        .gg
        {width:200px;height:200px;border:solid 1px red;}
        .big
        {
            width:1000px;
            height:1000px;
            border:solid 1px red;
            margin:100px 220px;
        }
        .c1
        {
            background:violet;
            /* 無效 */
            position: relative; 
        }
        .c2
        {
            background:tan;
            position: absolute;
            top:0px;
            left:0px;
            /* bottom:0px;
            right:0px; */
            /* z-index:-1; */
        }
        .c3
        {background:blue;}
        .c4
        {background:green;}
    </style>
</head>
<body>
    <!-- 
        絕對定位:參考點默認(rèn)參考的是body 
        效果:脫離文檔流,后面的內(nèi)容自動補(bǔ)位
        使用:絕對定位會參照父級的相對定位進(jìn)行移動,如果父級中沒有relative,相對于body進(jìn)行定位;
            (1)把想要的父級元素變成relative
            (2)把要定位的元素變成 absolute
    -->
    <div class="big">
        <div class="c1 gg"></div>
        <div class="c2 gg"></div>
        <div class="c3 gg"></div>
        <div class="c4 gg"></div>
    </div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>定位:絕對定位 absolute</title>
    <style>
        .gg
        {width:200px;height:200px;border:solid 1px red;}
        .big
        {
            width:1000px;
            height:1000px;
            border:solid 1px red;
            margin:100px 220px;
        }
        .c1
        {
            background:violet;
            /* 無效 */
            position: relative; 
        }
        .c2
        {
            background:tan;
            position: absolute;
            top:0px;
            left:0px;
            /* bottom:0px;
            right:0px; */
            /* z-index:-1; */
        }
        .c3
        {background:blue;}
        .c4
        {background:green;}
    </style>
</head>
<body>
    <!-- 
        絕對定位:參考點默認(rèn)參考的是body 
        效果:脫離文檔流,后面的內(nèi)容自動補(bǔ)位
        使用:絕對定位會參照父級的相對定位進(jìn)行移動,如果父級中沒有relative,相對于body進(jìn)行定位;
            (1)把想要的父級元素變成relative
            (2)把要定位的元素變成 absolute
    -->
    <div class="big">
        <div class="c1 gg"></div>
        <div class="c2 gg"></div>
        <div class="c3 gg"></div>
        <div class="c4 gg"></div>
    </div>
</body>
</html>

2.3 固定定位

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>定位:固定定位 fixed</title>
    <style>
        /* *號代表通配選擇符,代表所有標(biāo)簽,默認(rèn)標(biāo)簽中含有默認(rèn)的間距,要在一開始的時候全部去掉; */
        *
        {margin:0px;padding:0px;}
        body
        {height:2000px;}
        .c1
        {
            width:500px;
            height: 600px;
            border:solid 1px red;
            background-color: green;
            position: fixed;
            left:50%;
            margin-left:-250px;
            top:50%;
            margin-top:-300px;
        }
        /* 
        <' transition-property '>: 檢索或設(shè)置對象中的參與過渡的屬性 
        <' transition-duration '>: 檢索或設(shè)置對象過渡的持續(xù)時間 
        <' transition-timing-function '>: 檢索或設(shè)置對象中過渡的動畫類型 
        <' transition-delay '>: 檢索或設(shè)置對象延遲過渡的時間  
        */
        img
        {
            position:fixed;
            bottom:20px;
            left:-100px; 
            transition: all 1s ease 0.1s;           
        }
        
        img:hover
        {
            left:0px;
            background-color: red;
        }

    </style>
</head>
<body>
     <img src="images/xiao.jpg"/>
     <div class="c1">我沒動</div>
     <p>1111222333444</p>
</body>
</html>

3. float浮動

3.1 display轉(zhuǎn)換元素

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>display 轉(zhuǎn)換元素</title>
    <style>
        div
        /* display:inline; 轉(zhuǎn)換成行內(nèi)元素 */
        {display:inline;border:solid 1px red;width:1000px;height:20px;}
        span
        /* display:block; 轉(zhuǎn)換成塊狀元素 */
        {display:block;width:100px;height:50px;border:solid 1px red;}
        a
        /* display:inline-block; 轉(zhuǎn)換成行內(nèi)塊狀元素 */
        {display:inline-block;width:500px;height:30px;border:solid 1px red;}        
        p
        /* display:none 隱藏元素 */
        {display:none;}
    </style>
</head>
<body>
    <!-- 元素的分類:
        塊狀元素 : block
        行內(nèi)元素 : inline
        行內(nèi)塊狀元素  : inline-block
    -->
    <div>第一個div</div>
    <div>第二個div</div>
    <span>我是span1</span>
    <span>我是span2</span>
    <a href="#">我是鏈接1</a>
    <a href="#">我是鏈接2</a>
    <p>12345</p>
</body>
</html>

3.2 float浮動

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>float 浮動</title>
    <style>
        .content
        {width:700px;clear:both;}
        .content .c1
        {background: red;width:100px;height:100px;float:left;}
        .content .c2
        {background: tan;width:100px;height:100px;float:left;}
        .content .c3
        {background:blue;width:100px;height:100px;float:left;}
        .content .c4
        {background:green;width:100px;height:100px;float:left;}
        .content2
        {width:700px;height:500px;border:solid 1px red;clear:both;}
        #a1
        {float:left;width:100px;height:100px;border:solid 1px red;}
        #a2
        {display:block;width:100px;height:100px;border:solid 1px red;background: teal;clear: both;}
    </style>
</head>
<body>
    <!-- 
    # ###塊狀元素浮動:
    float:left  向左浮動  ,元素脫離原始文檔流,后面的內(nèi)容自動補(bǔ)齊;
    float:right 向右浮動  ,元素脫離原始文檔流,后面的內(nèi)容自動補(bǔ)齊;
    目的: 讓塊狀元素在一排顯示 
    clear:both; 清除兩邊的浮動
    -->
    <div class="content">
        <div class="c1"></div>
        <div class="c2"></div>
        <div class="c3"></div>
        <div class="c4"></div>
    </div>
    <!-- 
    # ###行內(nèi)元素浮動:
        如果對行內(nèi)元素進(jìn)行浮動:
        默認(rèn)會把行內(nèi)元素升級成行內(nèi)塊狀元素,可以設(shè)置寬和高 
        消除浮動產(chǎn)生的影響:clear:both;
    -->
    <div class="content2">
        <a href="#" id="a1">點擊我跳轉(zhuǎn)1</a>
        <a href="#" id="a2">點擊我跳轉(zhuǎn)2</a>
    </div>
</body>
</html>

4. html里面的bug

4.1 float內(nèi)容塌陷問題

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>float 浮動</title>
    <style>
        .content
        {width:700px;clear:both;}
        .content .c1
        {background: red;width:100px;height:100px;float:left;}
        .content .c2
        {background: tan;width:100px;height:100px;float:left;}
        .content .c3
        {background:blue;width:100px;height:100px;float:left;}
        .content .c4
        {background:green;width:100px;height:100px;float:left;}
        .content2
        {width:700px;height:500px;border:solid 1px red;clear:both;}
        #a1
        {float:left;width:100px;height:100px;border:solid 1px red;}
        #a2
        {display:block;width:100px;height:100px;border:solid 1px red;background: teal;clear: both;}
    </style>
</head>
<body>
    <!-- 
    # ###塊狀元素浮動:
    float:left  向左浮動  ,元素脫離原始文檔流,后面的內(nèi)容自動補(bǔ)齊;
    float:right 向右浮動  ,元素脫離原始文檔流,后面的內(nèi)容自動補(bǔ)齊;
    目的: 讓塊狀元素在一排顯示 
    clear:both; 清除兩邊的浮動
    -->
    <div class="content">
        <div class="c1"></div>
        <div class="c2"></div>
        <div class="c3"></div>
        <div class="c4"></div>
    </div>
    <!-- 
    # ###行內(nèi)元素浮動:
        如果對行內(nèi)元素進(jìn)行浮動:
        默認(rèn)會把行內(nèi)元素升級成行內(nèi)塊狀元素,可以設(shè)置寬和高 
        消除浮動產(chǎn)生的影響:clear:both;
    -->
    <div class="content2">
        <a href="#" id="a1">點擊我跳轉(zhuǎn)1</a>
        <a href="#" id="a2">點擊我跳轉(zhuǎn)2</a>
    </div>
</body>
</html>

4.2 margin-top失效問題

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>margin-top失效問題</title>
    <style>
        *
        {margin:0px;padding:0px;}
        .box1
        {width:100px;height:100px;margin-top:10px;border:solid 1px red;}
        .father
        {width:300px;height:300px;background: yellow;overflow: hidden;}
        .son
        {width:150px;height:150px;margin-top:50px;}
    </style>
</head>
<body>
    <!-- overflow: hidden; overflow auto 如果內(nèi)容超出邊框,會以下拉框的形式顯示,不會溢出 -->
    <div class="box1">
        sdfsf
    </div>
    <div class="father">
        <div class="son">12</div>        
    </div>
</body>
</html>

4.3 overflow

<!DOCTYPE html>
<html>
    <head>
    <meta charset="utf-8" />
    <style>
        .test {
            overflow: hidden;
            width: 200px;
            height: 100px;
            background: #eee;
        }
    </style>
    </head>
    <body>
        <!-- overflow:hidden 對超出部分內(nèi)容進(jìn)行隱藏 -->
        <div class="test">
            <p>蘇打速度</p>
            <p>蘇打速度</p>
            <p>蘇打速度</p>
            <p>蘇打速度</p>
            <p>蘇打速度</p>
        </div>
    </body>
</html>

總結(jié)

本篇文章就到這里了,希望能夠給你帶來幫助,也希望您能夠多多關(guān)注腳本之家的更多內(nèi)容!

相關(guān)文章

最新評論

英德市| 潞西市| 玉树县| 莆田市| 邵阳市| 固原市| 科技| 天水市| 壶关县| 福建省| 平阳县| 博乐市| 望都县| 铁力市| 云和县| 武平县| 工布江达县| 南开区| 磴口县| 泰顺县| 阿鲁科尔沁旗| 德昌县| 高陵县| 绿春县| 攀枝花市| 洛浦县| 新绛县| 登封市| 太和县| 正宁县| 彰化市| 成都市| 达孜县| 闽清县| 商洛市| 伊宁市| 卢湾区| 云龙县| 栖霞市| 湘西| 会昌县|