1. 程式人生 > >css實現背景圖PC端/手機端自適應

css實現背景圖PC端/手機端自適應

css程式碼:

@charset "utf-8";

*{
	margin: 0px;
	padding: 0px;
	font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
	font-size: 12px;
}
a{
	text-decoration: none;
}
html{
	width: 100%;
	height: 100%;
	overflow-x:hidden; 
	overflow-y:auto;
}
body{
	width: 100%;
	min-height: 100%;
}
.login-bg{
	 background:url(./bg.png) no-repeat center;
    background-size: cover;
    overflow: hidden;
}

html程式碼:

<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title></title>
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8, target-densitydpi=low-dpi" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
</head>
<body class="login-bg">
//你的內容
</body>
</html>