彈性盒布局-寬度自動分配-圖片自適應


<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>彈性盒布局-寬度自動分配-圖片自適應</title>
    <style>
        *{ margin:0; padding:0}
        #parent { width:100%; background:#999; display:-webkit-box; height:auto;}
        #parent div { margin:5px;}
        /*將盒子進行平均分配的主要代碼*/
        /*.son1{ -webkit-box-flex:1; }*/
        /*.son2{ -webkit-box-flex:1; }*/
        /*.son3{ -webkit-box-flex:1; }*/
        /*.son3{ -webkit-box-flex:3; } */  /*假如此處為3,則此盒子是整個大盒子一塊的1/3*/
        .son1 img,.son2 img,.son3 img{
            width:100%;
            height: 100%;
        }
        .son1,.son2,.son3{
            position: relative;
            -webkit-box-flex:1;
        }
        .son1 span,.son2 span,.son3 span{
            position: absolute;
            left: 0;
            right: 0;
            bottom: 0;
            top:0;
            margin: auto;
            text-align: center;
            width: 100%;
            height: 20px;
            white-space:nowrap;/*禁止文字自動換行*/
        }
    </style>
</head>
<body>
        <div id="parent">
            <div class="son1">
                <img src="test_img/111.jpg" alt=""/>
                <span>內容區1的文字介紹</span>
            </div>
            <div class="son2">
                <img src="test_img/111.jpg" alt=""/>
                <span>內容區2的文字介紹</span>
            </div>
            <div class="son3">
                <img src="test_img/111.jpg" alt=""/>
                <span>內容區3的文字介紹</span>
            </div>
        </div>
</body>
</html>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM