CSS如何实现body背景层高于块元素的方法
这篇文章将为大家详细讲解有关CSS如何实现body背景层高于块元素的方法,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。
具体实现方如下:
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>demo</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>
效果如下:
关于CSS如何实现body背景层高于块元素的方法就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。