HTML5中margin使用技巧

貓哥的魚庫發表於2017-12-13

這裡寫圖片描述

<!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>Document</title>
    <style>
        .box{
            width: 200px;
            height: 200px;
            border: 10px solid green;
            /* 讓元素居中 */
            /* margin: 0 auto; */
        }
        .box1{
            width: 200px;
            height: 200px;
            border: 10px solid green;
            /* 負值合併邊框 */
            margin-top: -10px; 
        }    
    </style>
</head>
<body>
    <div class="box"></div>
    <div class="box1"></div>    
</body>
</html>

相關文章