html - CSS margin-top on inner div pushing parent div down -


this question has answer here:

i trying push child div down 5px inside of parent div. when put margin-top:5px; on inner div pushes down both inner div , parent div div above parent div, not push inner div down parent div. how set inner div pushed down 5px parent div? not want parent div push down div above it. help.

html navigation:

<nav>     <div class="nav-container">       <div id="cat_14623_divs">           <ul id="nav_14623">               <li><a href="#" onclick="return false;">akina &amp; red lake</a</li>                      <li><a href="#" onclick="return false;">fresh wild caught fish</a>                    <ul id="navsub_14623_2326">                        <li><a href="#" onclick="return false;">walleye</a></li>                        <li><a href="#" onclick="return false;">perch</a></li>                        <li><a href="#" onclick="return false;">crappie</a></li>                        <li><a href="#" onclick="return false;">northern</a></li>                        <li><a href="#" onclick="return false;">whitefish</a></li>                   </ul></li>               <li><a href="#" onclick="return false;">news fishery</a></li>               <li><a href="#" onclick="return false;">contact us</a></li>               <li class="last"><a href="#" onclick="return false;">faqs</a></li>          </ul>       </div>     </div> </nav> 

css navigation:

nav{ position:relative; width:960px; background-color:#660000; height:40px; }  div.nav-container{ position:relative; width:100%;  }  #cat_14623_divs{ margin-top:5px; height:30px; background-color:#520000; width:960px;     }  #nav_14623{ list-style:none; display:block; padding:0; width:80%; margin:0 auto; }  #nav_14623 li{ position:relative; float:left; padding: 0.5em 1.5em; margin: 0px; font-size:12px; border-right:solid 2px #fff; text-align:center;   }  #nav_14623 li.last{ border-right:none; padding-right:5px; }  #nav_14623 li a{ color:#fff; text-decoration:none; }  #nav_14623 ul{ position: absolute; left:0; top: 100%; display: none;     padding: 0 1000em; /* trick css-tricks comments */     margin: 0 -1000em; /* trick css-tricks comments */ list-style: none; margin-left: 0px; margin: 0; padding: 5px; width:200px; z-index: 1000; background: #660000;     border-left: 1px solid #336699;     border-right: 1px solid #336699;     border-bottom: 1px solid #336699;     border-top: none;  }  #nav_14623 ul li{ position: relative; float: none; border-right: none; padding:0; margin: 0; }  #nav_14623 ul li a{ color: #fff; font-size: 12px; vertical-align: middle; line-height:32px; width: 100%; height:35px; display:block; }  #nav_14623 ul li a:hover{ background: #520000; width: 100%; }  #nav_14623 li:hover > ul{ display: block; }  #nav_14623:after { content: ""; clear: both; display: block; } 

here url in case want see site: http://redlakewalleye.designangler.com/

instead of margin-top on child, should use padding-top parent.

updated (as reaction on comment)

a margin needs bounce on. since parent div has nothing bounce on, bounce on element above it. therefor should use padding.


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -