我使用以下 CSS:
background-size: 100% auto;
background:url(Top.jpg);
background-repeat:no-repeat;
background-position:center top;
min-height:800px;
当屏幕尺寸改变时,我有响应式背景图片,但当屏幕尺寸小于最小高度时,响应式背景图片周围出现空白区域。我希望当屏幕变得小于最小高度时,div 的高度会自动改变。
最佳答案
改用background-size: cover
。
background: ("Top.jpg") no-repeat center top fixed;
background-size: cover;
/* For older browsers */
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
min-height:800px;
参见 https://css-tricks.com/perfect-full-page-background-image/
关于css - 调整屏幕大小时背景图像响应空白,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31098764/