简体   繁体   English

消除页面底部的空白

[英]Eliminating white space at bottom of page

Originally I had a background image that appeared as a gradient background.最初我有一个背景图像显示为渐变背景。 Wanting to have a solid black backgound I removed link to background image/repeat x.想要有一个纯黑色背景,我删除了指向背景图像/重复 x 的链接。 The result is a large white space at bottom of page.结果是页面底部有一个大的空白区域。 I have searched quite a few answers to this common problem but none have helped me figure this out.我已经搜索了很多这个常见问题的答案,但没有一个能帮助我解决这个问题。

This is an .php site so if there is an html .div then I cannot find it but in css stylesheet it just reads as #top-bg with background: #000000这是一个 .php 站点,所以如果有一个 html .div 那么我找不到它,但在 css 样式表中它只是读取为 #top-bg with background: #000000

I have tried adding in height: 100%;我试过增加高度:100%; not sure where to adjust margins as recommended by some sites.不确定在某些网站推荐的哪里调整边距。 Any help would be greatly appreciated!任何帮助将不胜感激!

body, html{
    padding:0!important; 
    margin:0 !important;

    background:#000;//is this what you want?
}

for start have you think to remove defaukt browser padding and margin?首先,您是否考虑删除默认浏览器填充和边距?

html{
    margin: 0;
    padding: 0;
}

Also, where is define your background?另外,在哪里定义你的背景?

  • in your first div?在你的第一个 div 中?
  • in your body?在你的身体里?
  • in your HTML ?在你的 HTML 中?

for better, background was define in your body tag :更好的是,背景是在你的身体标签中定义的:

body{
    background-color: #FCC; /* for test */
}

If you have no padding, no margin, this code working for you...如果您没有填充,没有边距,则此代码适合您...

Try this试试这个

body, html {

background:#000;
height:100%;
padding:0;
margin:0


}
html {
  background:#000;
}

This was sufficient for me to remove white space.这足以让我删除空白。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM