本文實例講述了CSS實現body背景層高於塊元素的方法,分享給大家供大家參考。具體實現方法如下:
復制代碼代碼如下:
<!DOCTYPE Html>
<Html lang="en">
<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 class="box"></div>
</body>
</Html>
希望本文所述對大家基於CSS的網頁設計有所幫助。