通过background-size设定背景图片大小。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>背景图片</title>
<style type="text/css">
div {
width: 600px;
height: 600px;
background: url(imgs/tudou.jpg) no-repeat;
border: 1px solid red;
/* background-size: 用来定义背景图片大小 */
/* background-size: 300px 300px; */
/* background-size: 300px auto; */
/* background-size: cover; */
background-size: contain;
}
</style>
</head>
<body>
<div></div>
</body>
</html>