Welcome to WebmasterWorld Guest from

Forum Moderators: not2easy

Message Too Old, No Replies

Positioning content over fixed background image



4:44 pm on Nov 8, 2011 (gmt 0)

10+ Year Member

I have a background pic on a webpage that I've set to a "fixed center center" position, so that it remains centered on the user's screen regardless of browser window size.

I have a text block that I want to display at a set position relative to the pic (i.e. I want it to display over a certain part of the image -- the white space).

Is there a way to do that?


9:22 pm on Nov 8, 2011 (gmt 0)

10+ Year Member


If you have a background image using background-attachment:fixed then the image is relative to the viewport and will not scroll with the document.

If you want to place a div over part of that image and for it to not also scroll with the document then use position:fixed (not supported in IE6) as all fixed elements are relevant to the viewport.

You'll need to know the dimensions of the box and do something like this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
<style type="text/css">
body{background:url(img.gif) fixed 50% 50% no-repeat}
.box {
border:1px solid #000;

<div class="box">
<p>Text Box</p>

However, that means you can't have any other scrollable content on the page because it will most likely scroll over the top of that fixed element unless you can make allowances or perhaps that's the effect you were after.


11:07 pm on Nov 8, 2011 (gmt 0)

10+ Year Member

Thanks Paul -- that's perfect.

Featured Threads

Hot Threads This Week

Hot Threads This Month