当html和body高度设置为100%时,背景剪切 [英] Background cuts off when html and body height are set to 100%

查看:217
本文介绍了当html和body高度设置为100%时,背景剪切的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的html和body设置为100%的高度,并且在body上设置了背景图片,如下所示,它在向下滚动时会截断。

I have my html and body set to 100% height, and a background image set on body, which gets cut off when scrolling down, as shown below.

但是,YouTube有100 html和body上的%height,以及body上的背景,它延伸到内容的完整高度。

However, YouTube has 100% height on html and body, and a background on body, and it stretches to the full height of the content. How can I achieve this?

推荐答案

如果原因,你把100%的高度是背景(作为您的评论之一),然后将其更改为 min-height:100%,您应该没有问题。您将在短页上达到100%的高度,但在更长的页面上可以根据需要扩展。

If the only reason you put the 100% height is for the background (as one of your comments seems to suggest), then just change that to min-height: 100% and you should have no issues. You will have 100% height on short pages, but expand to as much as you need on longer pages.

这篇关于当html和body高度设置为100%时,背景剪切的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆