今天写了一个页面,页面背景是一张大图,要求适配不同屏幕大小,我采用以下方案:
html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="../css/login.css"><!-- 我的css代码路径 -->
<title>。。。</title>
</head>
<body>
<div class="container">
</div>
</body>
</html>
css:
html,
body {
100%;
height:100%;
}
.container {
100%;
height:100%;
min- 1200px;
background: url('../images/bg.jpg')no-repeat;
background-size: cover;
background-position: center 0;
}