4

Hi I am not sure if this is the right way to do it but I am trying to position a div tag back over the previous div element This is what I have working

example

my css that I have used to get this to work looks like

.page-frame {
background-color: #fff;
padding-top: 40px;
position: relative;
top: -35px;
}

so for the top part the div element looks the way I want it to however the bottom on the element hasn't adjusted for the -35px;

enter image description here

I have tried adding a clear div after the element however that doesnt help. What do I need to change to remove the space between my .page-frame div and the next div?

2
  • It would help if you could make a jsFiddle of your code. Commented Apr 6, 2012 at 23:44
  • That gap looks about 40px tall. Can you see the number anywhere in your CSS? Commented Apr 6, 2012 at 23:44

3 Answers 3

5

The use of position: relative only shifts the appearance of the element in the page, but not the actual "space" it takes up on the page. So what you have done made your visual change to show the element 35px higher, but it does not cause other elements to reflow around it. Probably, what you need to add is a margin-bottom: -35px to get the final effect you want.

EDIT: Added better fiddle example to show reflow with margin.

Sign up to request clarification or add additional context in comments.

Comments

2

Use position: absolute; instead of relative

Comments

0

If you want to position one element over some other one which is higher in the hierarchy, using z-index CSS property worth considering to use, see for more: https://developer.mozilla.org/en-US/docs/Web/CSS/z-index

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.