2011-03-24 27 views
2

我有一些小图像,有一些装饰,我需要坚持到页面的右上角。但无论我使用了多少种不同类型的代码,我都无法做到。固定div无论使用哪种浏览器大小

这个页面顶部有点像“欢迎来到Q & A”,它无论滚动多远都会停留在那里。

我只需要使用包含图像的方式来做到这一点,即使我调整大小,该图像也会粘在浏览器的右边距上。

你可以看一下网站http://dawtano.com/pp/,看到的图像,这是目前在页面中间..

回答

2

你只需要指定背景的重力right top

#deco { 
    background: url("images/header-deco.png") no-repeat scroll right top transparent; 
    height: 375px; 
    margin-top: 7px; 
    width: auto; 
} 
+1

太棒了,感谢您的快速答案。 – 2011-03-24 18:29:10

2

应用{background-position: right top;}背景图像。

1

如果我unsterstand你的问题正确: 使用位置:固定和顶部,就在你的CSS

哦,it's背景图像... 使用background-position:右上角;

0

我假设你是指#deco div。如果是这样,根据你当前的例子,这应该工作:

<style> 
    background-image: url(images/header-deco.png); 
    background-repeat: no-repeat; 
    width: 599px; /*you must give an actual width here instead of auto*/ 
    height: 375px; 
    position: fixed; 
    top: 7px; 
    right: 0; 
</style> 
相关问题