简体   繁体   English

html页面底部的空白

[英]White space on the bottom of html page

When I made my HTNL page, it looked perfect, but all of a sudden, I've been getting this huge white space on the bottom of my page. 当我制作HTNL页面时,它看起来很完美,但是突然之间,我在页面底部得到了巨大的空白。 you can see it at http://thomaswd.com/pearinc2 . 您可以在http://thomaswd.com/pearinc2上看到它。 How do I get rid of this?! 我该如何摆脱呢? My stylesheet's at http://thomaswd.com/pearinc2/style.css 我的样式表位于http://thomaswd.com/pearinc2/style.css

If you look at the HTML element with the class back-iphone4s you'll notice it's positioned relatively using CSS. 如果您将HTML元素与back-iphone4s类一起查看,您会发现它使用CSS的位置相对较高。

If you remove the position: relative portion from the CSS rules for .back-iphone4s you'll notice it appears where your white space is. 如果从.back-iphone4s的CSS规则中删除position: relative部分,您会注意到它出现在空白位置。

Using position: relative like this is always horrible, white space appears where the element would have been if it wasn't positioned relatively. 使用position: relative喜欢这始终是可怕的,空白出现在元素本来如果它不是相对定位。

What I would recommend is adding position: relative to the div with devices as its class, then use position: absolute; 我建议添加position: relativedevices为类的div,然后使用position: absolute; on .back-iphone4s and set it's position using that method. .back-iphone4s并使用该方法设置其位置。 This way the back-iphone4s element is positioned relatively to it's parent, not relatively to where it would be in the normal document flow. 这样, back-iphone4s元素相对于其父元素放置,而不是相对于普通文档流中的位置。

There are are a number of other ways you could solve this too, at I glance I would be very tempted to just turn those two iphones into one image, less HTML, less CSS and less images to download, but it appears you may have inteneded them to be seperate for a purpose, so maybe that's not a viable solution. 您也可以通过多种其他方式解决此问题,乍一看,我很想将这两个iPhone变成一个图像,减少HTML,减少CSS,减少下载图像,但是您似乎有意出于某种目的将它们分开,所以也许这不是可行的解决方案。

... phew, hope that makes sense, let me know if now. ...,希望这有意义,让我知道是否现在。

.devices类一个height

.devices {height: 520px;}

I just had a quick look at your style, what I saw is technically very ugly. 我只是快速浏览了一下您的样式,从技术上看,我觉得这很丑陋。 You set all main elements with position:absolute and made them independent from context and content-flow. 您将所有主要元素设置为position:absolute,并使它们独立于上下文和内容流。 And because they are absolute, you have to give them a height - and that causes in things like that ugly white-space. 而且由于它们是绝对的,因此您必须给它们一个高度-这会导致类似丑陋的空白。 I would say you have the wrong concept of styling / structuring the page. 我会说您对页面样式/结构的概念有误。

Try to use "position:absolute" very rare! 尝试使用“ position:absolute”非常罕见!

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

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