天天看點

css 使用background的時候自适應圖檔高度

定義容器

将容器定位到底部,設定高度為100%

.container{
	width: 100%;
	height: 100%;
	position: absolute;
	bottom: 0;
	background: url('./img/test.jpg') no-repeat;
	background-size: 100% 100%;
}
           

這樣就可以讓圖檔在不用固定高度的情況下,占滿整個螢幕