0

.con 类样式中padding改成margin为什么不行?

<!-- 圣杯布局 -->
<!DOCTYPE html>
<html>
<head>
    <style>
        .con {
            padding: 0px 190px 0px 150px;//改成margin为什么不行
            overflow: auto;
        }

        .left {
            background: #E79F6D;
            width: 150px;
            float: left;
            position: relative;
            left: -150px;
            margin-left: -100%;
            /*left: -100%;*/
            /*margin-left: -150px;*/
        }

        .main {
            background: #D6D6D6;
            width: 100%;
            float: left;
        }

        .right {
            background: #77BBDD;
            width: 190px;
            float: left;
            position: relative;
            margin-left: -190px;
            right: -190px;
            /*left: 190px;*/
        }
    </style>
</head>
<body>
<div class="con">
    <div class="main">
        nihaollelelel
    </div>
    <div class="left">Left</div>
    <div class="right">Right</div>
</div>
</body>
</html>  

1个回答

0

已采纳

padding是算在元素大小里面的,你用margin会压缩元素的大小.

撰写答案