DIV高度怎么设置全屏?

2025-05-02 10:18:24
推荐回答(1个)
回答1:

要想对DIV设置全屏,一般设置其width宽度样式为100%,设置其width宽度样式为100%有两种方案,具体方案如下。

(一)方案一

1.Html:

头部DIV

下部DIV

2.CSS:

html,

body { height: 100%; padding: 0; margin: 0; }

.outer { height: 100%; padding: 100px 0 0; box-sizing: border-box ; position: relative; }

.A { height: 100px; background: #BBE8F2; position: absolute; top: 0 ; left: 0 ; width: 100%; }

.B { height: 100%; background: #D9C666; }

(二)方案二

Html:

头部DIV

下部DIV

2.CSS:

html,

body { height: 100%; padding: 0; margin: 0; }

.outer { height: 100%; padding: 100px 0 0; box-sizing: border-box ; }

.A { height: 100px; margin: -100px 0 0; background: #BBE8F2; }

.B { height: 100%; background: #D9C666; }