Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8947289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:43:12+00:00 2026-06-15T12:43:12+00:00

The problem occurs is the following: After relative positioning an element with CSS I

  • 0

The problem occurs is the following:
After relative positioning an element with CSS I get a white-space of where the element was… I don’t want the white-space!

    .thetext 
    {
        width:400px;
        background:yellow;
        border: 1px dashed red;
        margin:50px;
        padding:5px;
        font-weight:bold;
    }
    .whiteblob
    {
        position:relative;
        top:-140px;
        left:70px;
        width:200px;
        height:50px;
        border: 4px solid green;
        background:white;
        font-size:2.5em;
        color:red;
        
    }
    .footerallowedwhitespaceinblue
    {
        height:10px;
        background-color:blue;
    }
    .footer
    {
        background-color:grey;
        height:200px;
    }
<div class="thetext"><script type="text/javascript">for(c=0;c<50;c++){document.write("Lorem ipsum dolor est, ");}</script>
    </div>
    <div class="whiteblob">
        &nbsp;buy this!
    </div>
    <div class="footerallowedwhitespaceinblue">
    </div>
    <div class="footer">
        The whitespace above is way to big! The buy this still takes up space whilst it is moved.
    </div>

JSFiddle: http://jsfiddle.net/qqXQn/

As you can see in the example, the only whitespace I want is the whitespace caused by the thetext block by the margin of 50px; and the spacing by the footerallowedwhitespaceinblue(made blue so it’s visible).
The problem is… the whitespace is too big now because the “buy this” div still takes up space after it’s been relatively positioned.

How do I solve this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T12:43:18+00:00Added an answer on June 15, 2026 at 12:43 pm

    You can simply solve this by applying a negative margin that equals the width or height of the element.

    For an element of 100px height that is positioned to the top you will apply margin-bottom:-100px;

    For an element of 100px height that is positioned to the bottom you will apply margin-top:-100px;

    For an element of 100px width that is positioned to the left you will apply margin-right:-100px;

    For an element of 100px width that is positioned to the right you will apply margin-left:-100px;

    cut & paste css snippets:

    .top 
        {
        postion:relative;
        top:-100px;
        height:25px;
        margin-bottom:-25px;
        }
    .bottom
        {
        postion:relative;
        top:100px;
        height:25px;
        margin-top:-25px;
        }
    .left
        {
        postion:relative;
        left:-100px;
        width:25px;
        margin-right:-25px;
        }
    .right
        {
        postion:relative;
        left:100px;
        width:25px;
        margin-left:-25px;
        }
    

    And the reworked example code becomes then:

    .thetext 
    {
        width:400px;
        background:yellow;
        border: 1px dashed red;
        margin:50px;
        padding:5px;
        font-weight:bold;
    }
    .whiteblob
    {
        position:relative;
        top:-140px;
        left:70px;
        width:200px;
        height:50px;
        margin-bottom:-50px;
        border: 4px solid green;
        background:white;
        font-size:2.5em;
        color:red;
        
    }
    .footerallowedwhitespaceinblue
    {
        height:10px;
        background-color:blue;
    }
    .footer
    {
        background-color:grey;
        height:200px;
    }
    <div class="thetext"><script type="text/javascript">for(c=0;c<50;c++){document.write("Lorem ipsum dolor est, ");}</script>
    </div>
    <div class="whiteblob">
        &nbsp;buy this!
    </div>
    <div class="footerallowedwhitespaceinblue">
    </div>
    <div class="footer">
    </div>

    http://jsfiddle.net/qqXQn/1/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've the following problem: I'm accessing foursquares Venue API and get a JSON string
Current System: Windows XP / Windows 7 (problem occuring for both) After following the
The problem occurs when I do a division operation. I would like to know
Strange problem occurs on the production platform (64 bit win 2008 server). It is
The problem occurs when i try to manipulate an image uploaded from sinatra. File.open(params[:file][:tempfile])
Note: This problem occurs only on Mac, on Windows works fine. I have a
Seems like cuke doesn't show the full error message (at least when problem occurs
When i put an NSOpenglView in NSSplitView, a problem occurs while dragging splitter. The
Tomcat does not encode correctly String literals that contain unicode characters. The problem occurs
I have a problem that occurs only in a production environment, deployed at heroku.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.