html5——盒子模式

box-sizing属性

box-sizing: border-box;/*内减模式*/
box-sizing: content-box;/*外加模式(默认值)*/
box-sizing: padding-box;/*内减模式*/
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        div {
            margin: 150px auto;
            width: 512px;
            height: 341px;
            box-sizing: border-box;
        }

        div:hover {
            border: 12px solid #ccc;
        }

        img {
            width: 100%;
            height: 100%;
        }
    </style>
</head>
<body>
<div>
    <img src="images/shanshui.jpg">
</div>
</body>
</html>

posted @ 2017-12-18 14:07  var_obj  阅读(360)  评论(0编辑  收藏  举报