1. 程式人生 > >盒模型

盒模型

gin margin 內邊距 bsp top 為什麽 dot 通過 ott

CSS+DIV

將數據封裝到div中,頁面中都是有很多div組成的,通過css布局(通過css屬性布局)完成這些div位置的存放,一個div就是一個盒子。

邊框   border:{

      --left

      --right

      --top

      --bottom

    };

#div_1{

    border-top:1px solid #ccc;

    border-bottom:1px dashed #ccc;

    border-right:1px dotted #ccc;

    border-left:1px double #ccc;

};

solid:實線

dashed:虛線

dotted:點線

double:雙線

內邊距/內填充

屬性:padding{

      --top

      --bottom

      --right

      --left

};

padding:20px 20px 20px 20px;

外邊距

margin 屬性{

      --top

      --bottom

      --right

      --left

};

margin:20px 20px 20px 20px

在div中,如果margin是0,px,為什麽還要空白?那空白就是body本身距離瀏覽器邊框的距離。

所以要設置body{margin:0px};

瀏覽器解析body的方式不同,造成邊寬邊窄不同。

盒模型