製作html網頁時如何使用CSS使背景圖片拉伸(填充)
阿新 • • 發佈:2019-02-06
答案:
background-size: cover;
例1:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
body {
background-image: url(images/2.jpg);
background-size: cover;
}
</style>
</head>
<body>
</body>
</html>
例2:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
div {
width: 300px;
height: 300px;
background-image : url(images/2.jpg);
background-size: cover;
}
</style>
</head>
<body>
<div>哼哼哼</div>
</body>
</html>