CSS margin樣式屬性

2021-09-23 01:45:09 字數 2141 閱讀 5655

>

>

charset

="utf-8"

>

>

title

>

>

span

.instyle

>

head

>

>

style

="border

: 1px solid red;

height

: 300px;

width

: 300px;

margin-bottom

: 20px;

">

class

="in"

style

="background-color

: black;

">

div>

class

="in"

style

="background-color

: yellow;

margin-left

: 20px;

">

div>

class

="in"

style

="background-color

: green;

">

div>

div>

>

margin樣式屬性span

>

style

="margin-left

: 20px;

margin-right

: 30px;

margin-top

: 20px;

magin-bottom

: 20px;

">

margin樣式屬性span

>

>

margin樣式屬性span

>

style

="border

: 1px solid red;

height

: 300px;

width

: 300px;

margin-top

: 20px;

margin-bottom

: 20px;

">

class

="in"

style

="background-color

: black;

">

div>

class

="in"

style

="background-color

: yellow;

margin-left

: 20px;

">

div>

class

="in"

style

="background-color

: green;

">

div>

div>

style

="border

: 1px solid red;

height

: 300px;

width

: 300px;

">

class

="in"

style

="background-color

: black;

">

div>

class

="in"

style

="background-color

: yellow;

margin-left

: 20px;

">

div>

class

="in"

style

="background-color

: green;

">

div>

div>

body

>

html

>

效果:

對於塊級元素和行內元素都可以設定他們的外邊距。但是要注意他們相對的標籤。

CSS margin 屬性簡介

設定外邊距的最簡單的方法就是使用 margin 屬性。margin 屬性接受任何長度單位,可以是畫素 英吋 公釐或 em。margin 可以設定為 auto。更常見的做法是為外邊距設定長度值。下面的宣告在 h1 元素的各個邊上設定了 1 4 英吋寬的空白 h1下面的例子為 h1 元素的四個邊分別定義...

CSS margin屬性取值

margin表示乙個元素的外邊距。取值為正值時,表示相對於正常流離鄰近元素更遠,而取負值時,使其更近 但是,設定margin後,四個方向的表現形式不同 div id negtive top div margin top 50px 自身向上移動50px div margin left 50px 自身向...

CSS margin屬性與用法教程

margin屬性是css用於在乙個宣告中設定所有 margin 屬性的簡寫屬性,margin是css控制塊級元素之間的距離,它們之間是透明不可見的。margin屬性包含了margin left 距左元素塊距離 設定距左內邊距 margin top 距頭頂 上 元素塊距離 設定距頂部元素塊距離 mar...