开发者

CSS/HTML - Line appears at bottom of page

I am working on a site and have a solid line开发者_运维百科 appearing at the bottom of the page.

The Problem: http://jsfiddle.net/mxh6G/

The Details: I have a container element which has height: 99%;. I have also set up a gradient background effect (using only CSS). Now, beneath my main container element, there is a block of solid colour which matches the colour of the upper half of the gradient fill. However, please note that this is not what is causing the problem as even when I remove the gradient section of the CSS altogether, the blank line is still visible (I have set the background-color: of my container element to red so that I can see if the problem still persists).

For example, if the gradient fades from red (top) to black (bottom), the solid line at the bottom of the page is red.

I have set the height to 100% and even up to 150% for my container element and the solid line is still there.

An example might be like this:

+----------------------+
|   _________________  |
|  |        C       |  |
|  |        O       |  |
|  |        N       |  |
|  |        T       |  |
|  |        A       |  |
|  |        I       |  |
|  |        N       |  |
|  |        E       |  |
|  |        R       |  |
+______________________|
|______________________| <--- solid line appears here 
                              (but narrower, approx 5px in height).

Hopefully this gives you all a rough idea of what the problem is.

My HTML is absolutely fine - I have checked it thoroughly and there are no elements outside of the container <div> element.

I know that there could be any number of solutions, so to simplify things, I would like to ask if there are any commonly-known (or not-so-commonly-known) problems related to CSS which could cause this to happen?

Or, better still, has anybody else had this problem and if so, how did you rectify it (if applicable)?

Thanks for your time.

Mick

UPDATE: Here is the problem: I have set the top margin of container to 5px and it results in the bottom of the page also displaying a 5px margin from the bottom. If I set it to 0, however, then the margin at the bottom of the page is also set to 0.

Could somebody possibly figure out why this is happening?

(NOTE: You have to extend the frames outwards to view the page as it is intended and to also see the problem).

http://jsfiddle.net/mxh6G/


set this in css

body{margin:0; padding:0;}

or

* {margin:0; padding:0;}


This renders a black page (so you can see no margin at the bottom) with a white inner div called container, with a 5px margin on the top

  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  <html>

    <head>

        <style>
            body {margin:0; padding:0; background:#000;}
            #container {width:600px; height:600px; margin:5px auto 0 auto; background:#fff;}
        </style>

    </head>

    <body>

        <div id="container"></div>

    </body>

</html>


div {
border: 1px solid black;
}
.main {
position: relative;
height: 200px;
width: 200px;
}
.inner {
position: absolute;
bottom: 0px;
left: 0px;
right: 0px;
height: 30px; 
}

<div class="main">dasdasd<div class="inner">fdsfds</div></div>

Demo: http://jsfiddle.net/JS2y2/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜