user734063
user734063

Reputation: 569

CSS: How to get rid of space left by moved element?

I have an element that I moved right and then pushed up on top. It's lined up perfectly, but for some reason it still leaves the space it previously occupied below it. I tried clear, overflow, whitespace, negative-margins, visibility, block, etc. No joy. CSS doesn't seem to anticipate human thought.

 div.overlay-ad{

     position:relative;
     width:310px;
     height:260px;
     top:-332px;
     left:538px;

 }

Upvotes: 0

Views: 150

Answers (1)

Gareth Cornish
Gareth Cornish

Reputation: 4356

div.overlay-ad{
     position:absolute;
     width:310px;
     height:260px;
     top:-332px;
     left:538px;
}

The position: relative makes your block take up space in the flow. It doesn't matter that the visual rendering is then positioned away. position: absolute moves the block out of the general flow.

Upvotes: 1

Related Questions