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 9004869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:59:53+00:00 2026-06-16T00:59:53+00:00

Enlighten me a question: If I put a div inside another, in this second

  • 0

Enlighten me a question:

If I put a div inside another, in this second div I can’t use the properties margin-left and margin-top without changing the position of parent div?

I need to use padding instead??

EXEMPLE:

FIDDLE WITH MARGINS: http://jsfiddle.net/zyEYj/1/

FIDDLE WITHOUT MARGINS: http://jsfiddle.net/zyEYj/2/

FIDDLE WITH PADDING INSIDE MOTHER DIV: http://jsfiddle.net/zyEYj/3/ (this is the final effect i want, but i need to use padding, and change the height of #header)

codes:

<div id="header" class="container">
    <div class="logo">
        <a href="index.asp"><img src="imagens/logo.png" /></a>
    </div>
</div>​

css:

body{
background:#d3f1fc;        
}

#header{
    height:135px;
    background:#ee4b14;
    padding-top:35px;
    padding-left:21px;
}

.container {
    margin:0 auto;
    width:960px;
}

.logo{
    width:382px;
    height:114px;
    background:#FFCC00;
}​
  • 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-16T00:59:54+00:00Added an answer on June 16, 2026 at 12:59 am

    This behavior is referred to as margin collapse. Two adjacent margins will collapse into one another, with the higher absolute value taking precedence.

    This can be defeated either by separating the margins (via padding or border on the parent element), or by using position: relative on the child element, and adjusting its position that way.

    HTML:

    <div class="parent">
        <div class="child"></div>
    </div>
    

    CSS:

    Normal

    /*
        these margins will collapse, and result in a total margin of 15px
    */
    .parent
    {
        margin: 5px;
    }
    
    .child
    {
        margin: 15px;
    }
    

    Padding/Border solution

    /*
        these margins will be separate, resulting in a total margin of 20px
        plus the border or padding of 1px
    */
    .parent
    {
        margin: 5px;
        padding: 1px; /* or border: 1px; */
    }
    
    .child
    {
        margin: 15px;
    }
    

    Position: relative solution

    /*
        there is only one margin here, and the child
        is positioned relative to where it would usually be rendered
    */
    .parent
    {
        margin: 5px;
    }
    
    .child
    {
        position: relative;
        top: 15px;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please enlighten this flex noob. I have a remoteobject within my main.mxml. I can
I was asked in an interview to enlighten the ways one can use to
This question is very similar to this one Why can't I dynamic_cast "sideways" during
This question is asked by one of my students and I want to enlighten
I can see this question has been asked many times before, but I just
I have been looking all over for an answer to this question, but can't
Really basic LINQ question but can someone enlighten me as to how it handles
I’m afraid this is another noob question. What I want to do is to
Can anyone enlighten me to a way I can Highlight the content of an
Can anyone enlighten me as to why the following code won't work in IE7

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.