css——背景图片 保持比例不变形

2023-10-27

代码

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
		<style>
			html{
				height: 100%;
			}
			body{
				/* background: url('img/2.jpg') no-repeat top center;
				background-size: container; */
				background: url('img/1.jpg') no-repeat top center;
				background-size: cover;
			}
		</style>
	</head>
	<body>
		
	</body>
</html>

前者 长边显示出来
后者 短边显示出来

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

css——背景图片 保持比例不变形 的相关文章

随机推荐