Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Negative positioning creating large unwanted space

Featured Replies

Hi, I'd appreciated everybody's help. I have used relative and negative positioning to place a footer image (#containerFooter) underneath the main content of my site. For some reason, which I can't work out, it is adding a large space underneath the footer image.

 

Here's the page in question: happypawsredditch.co.uk/index1.html

 

Here's my CSS:

 

body {

background-image:url(../images/body-bg.gif);

background-repeat:repeat-x;

background-color:#A0DB53;

margin:0;

}

#containerMain {

width:980px;

margin:0 auto 0 auto;

}

#containerHeader {

width:980px;

height:188px;

float:left;

background-image:url(../images/header-bg-trans.png);

background-repeat:no-repeat;

}

#logo {

width:314px;

height:173px;

margin:0 0 0 29px;

float:left;

}

#contact {

font-family:Verdana, Geneva, sans-serif;

font-size:18px;

width:306px;

text-align:center;

float:right;

margin:49px 5px 0 0;

line-height:25px;

}

#contact a:link, #contact a:visited {

color:#443735;

font-size:16px;

text-decoration:none;

}

#contact a:hover {

color:#ED2274;

font-size:16px;

text-decoration:none;

}

.pink-text {

color:#ED2274;

}

#containerMenu {

width:162px;

height:249px;

background-image:url(../images/menu-bg-trans.png);

background-repeat:no-repeat;

float:left;

margin:0 0 0 1px;

}

#containerContent {

width:793px;

float:right;

margin:0 5px 0 0;

}

#contentTop {

background-image:url(../images/content-top-trans.png);

background-repeat:no-repeat;

width:793px;

height:24px;

float:left;

}

#contentBody {

background-image:url(../images/content-bg-trans.png);

background-repeat:repeat-y;

width:793px;

float:left;

min-height:366px;

}

#contentBase {

background-image:url(../images/content-base-trans.png);

background-repeat:no-repeat;

width:793px;

float:left;

height:254px;

}

.clear {clear:both;}

#containerFooter {

margin: 0 auto 0 auto;

height:470px;

background-image:url(../images/footer-bg.jpg);

background-repeat:no-repeat;

position:relative;

top:-430px;

z-index:-1;

}

 

Thanks in advance!

Using relative positioning and then moving it will always leave an empty space where the div 'would have been'.

 

You could try nesting your div containing the image within your 'containercontent' div with your z-index still set to -1?

 

Dave

  • Author

Using relative positioning and then moving it will always leave an empty space where the div 'would have been'.

 

You could try nesting your div containing the image within your 'containercontent' div with your z-index still set to -1?

 

Dave

 

Thanks Dave, but the #containercontent div is a different width, so would that work?

Thanks Dave, but the #containercontent div is a different width, so would that work?

 

You should be able to use relative positioning (relative to the #containercontent div) or use padding to position it in the correct position. Might need to make the #containercontent div wider to accomodate the image.

 

It's difficult to suggest anything without playing around with it myself, I would be happy to try if you want to PM me your files?

 

Dave

  • Author

I've changed the CSS slightly and it's working well in all browsers apart from IE. Any ideas how I can get this working in IE too?

 

happypawsredditch.co.uk/index1.html

 

#containerFooter {

margin: -430px auto 0 auto;

height:470px;

background-image:url(../images/footer-bg.jpg);

background-repeat:no-repeat;

z-index:-1;

 

}

  • Author

Problem solved. Removed the clear class, and applied this...

 

#containerFooter {

position:relative;

float:left;

height:470px;

background-image:url(../images/footer-bg.jpg);

width:100%;

margin-top:-430px;

z-index:-1;

 

}

 

Thanks for your help.

Problem solved. Removed the clear class, and applied this...

 

#containerFooter {

position:relative;

float:left;

height:470px;

background-image:url(../images/footer-bg.jpg);

width:100%;

margin-top:-430px;

z-index:-1;

 

}

 

Thanks for your help.

 

Ahh, negative margin-top, good thinking!

 

Glad you've sorted it, it looks good!

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.