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

代码

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>

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

你可能感兴趣的:(CSS,css,前端)