close


<!doctype html>
<html>
<head>
    <title>如何解決平均寬度問題</title>

    <meta charset="utf-8" />
    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <style type="text/css">

        .box1{

            width: 200px;
            height: 200px;
            background-color: tomato;
            float: left;
            padding: 5px;
            border: 5px solid black;
            margin: 5px;
            box-sizing: border-box; // 如沒有設定box-sizing:border-box則box1在瀏覽器上會出現220*220尺寸

        }

        .box2{

            width: 200px;
            height: 200px;
            background-color: orange;
            float : right;

        }

        .img-container{

            width: 33.33%;
            float: left;
            padding: 5px;
            box-sizing: border-box;

//設定box-sizing:brder-box;  元素的內距padding和邊框border將不會增加元素本身的寬度 ,不包含margin
        }

        .clearfix{

            clear:both; 
        }

    </style>    
</head>

<body>
<div>
    <h1>Example Domain</h1>

    <div class="box1"></div>
    <div class="box2"></div>

    <div class="clearfix">
        <div class="img-container">
            <img src="Image/earth.png" alt="first imagee" style="width:100%;">
        </div>
        <div class="img-container">
            <img src="Image/flat.png" alt="second imagee" style="width:100%;">
        </div>
        <div class="img-container">
            <img src="Image/woody.jpeg" alt="third imagee" style="width:100%;">
        </div>

    </div>
</div>
</body>
</html>

 

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 A&B 的頭像
    A&B

    網頁前端新手上路辛酸史

    A&B 發表在 痞客邦 留言(0) 人氣()