本文实例讲述了CSS实现body背景层高于块元素的方法,分享给大家供大家参考。具体实现方法如下:
复制代码代码如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
<!DOCTYPE html> < html > < head > < meta charset = "UTF-8" > < title >demo-www.zzarea.com</ title > < meta name = "viewport" content = "width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui" > </ head > < style > html, body{ width: 100%; max-width: 640px; height: 100%; overflow-x: hidden; margin: 0 auto; background-color: #000; font-family: 微软雅黑, 华文细黑, 黑体; } body{ background-image: url('img/person1.png'); background-repeat: no-repeat; background-position: bottom; background-color: transparent; background-size: 100%; } .box{ width: 100%; height: 50%; background-color: green; z-index: -1; position: absolute; } </ style > < body > < div ></ div > </ body > </ html > |