2014-05-23 60 views
0
body { 
    height: 100%; 
    background-color: #f8f8f8 ; 
    background-image: url('images/bottom-right.png'); /*Images*/ 
    background-position: right bottom; /*Positioning*/ 
    background-repeat: no-repeat; /*Prevent showing multiple background images*/ 
} 

所以我有这个代码,把图像放在身体的右下角,但问题是它没有以我想要的方式定位。它向右而不是在底部。它只与内容中的内容一样高,就像div或其他任何内容一样。你能帮我实现我想要的吗?HTML - 身高不是100%

这里是图像 - >http://tinypic.com/view.php?pic=2iabd3p&s=8感谢

+0

你重新设置'margin'和'padding'吗? – esswilly

+0

你可以只使用绝对定位'底部:0'的div,'right:0'? – nickpish

+0

如果j08691的答案奏效,你应该接受他的答案。 – John

回答

4

您还需要设置在html高度和去除身体上的保证金:

body { 
    height: 100%; 
    background-color: #f8f8f8; 
    background-image: url('http://www.placehold.it/100x100'); 
    background-position: right bottom; 
    background-repeat: no-repeat; 
    margin:0; 
    padding:0; 
} 
html { 
    height:100%; 
} 

jsFiddle example

+0

哇谢谢你vry mch ...它解决了我的问题.... – Pantamtuy

1

简单的设置在所有情况下,height: 100%;都不会起作用。虽然我一般不喜欢使用CSS2 position这可能会帮助你在这种情况下...

body, html 
{ 
bottom: 0px; 
left: 0px; 
overflow: auto; 
position: absolute; 
right: 0px; 
top: 0px; 
} 
+1

在什么情况下不会'身高:100%'工作..?它一直在我以前的工作.. j08的答案似乎适用于OP。 –