Div標籤使用inline block有間距

2022-08-26 02:30:11 字數 1184 閱讀 6161

doctype html

>

<

html

lang

="en"

>

<

head

>

<

meta

charset

="utf-8"

>

<

title

>document

title

>

<

style

>

*.c1

.c2style

>

head

>

<

body

>

<

div

class

="c1"

>

div>

<

div

class

="c2"

>

div>

body

>

html

>

兩個div設定行內塊屬性,內外邊距已經設定為0了,但是兩個div之間為什麼還有間隙呢?修改如下

doctype html

>

<

html

lang

="en"

>

<

head

>

<

meta

charset

="utf-8"

>

<

title

>document

title

>

<

style

>

*.c1

.c2style

>

head

>

<

body

>

<

div

class

="c1"

>

div><

div

class

="c2"

>

div>

body

>

html

>

將body中的連個div設定為一行就可以了。

HTML標籤之div標籤

div標籤的重要作用 1 劃分區域,使 更具有邏輯性 2 可結合css針對該區域進行樣式控制 看乙個沒有使用div標籤的示例,如下 doctype html html head title 這是頁面標題 title meta name keywords content 自學h5 h3 靜夜思 h3 ...

div標籤的設定

div基本設定 width 寬height 高background 背景background color 背景色 英文單詞 十六進製制 rgb 背景圖background image url 路徑 背景圖平鋪 background repeat no repeat repeat x repeat y...

div標籤消除浮動

1 第乙個div 第二個div 1 的截圖為,可以看到,id2和id3並沒有在id1中。這就是沒有清除浮動的效果。清除浮動的方法 1 對父級設定合適的高度 對父級設定合適的高度進行清除浮動,父級內內容的高度為20px 2px 22px,在id1中增加樣式height 22px 即可。效果圖 缺點 對...