开发者

Fixed div no matter which browser size

I have a little image, with some decoration, that I need to stick to the top-right corner of my page. But no matter how many different types of code I've used, I can't get it right.

It's sort of like the "Welcome to Q&A for professional.." on top of this page, it stays there no matter how far down I scroll.

I just need to do this with a conta开发者_StackOverflow中文版ining an image, that sticks to the right-margin of the browser, even if i resize.

You can look at the website http://dawtano.com/pp/ and see the image, that's currently in the middle of the page..


You just need to specify the gravity of the background to right top.

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


Apply {background-position: right top;} to the background image.


If i unsterstand your question correct: Use position: fixed and top, right in your css

Oh, it´s a background-image... Use background-position:right top;


I assume you mean for the #deco div. If so, based on your current example, this should work:

<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>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜