• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Strange CSS behaviour

 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can anyone please explain me why the top and bottom margins of the inner box comes as zero in the output (http://jsbin.com/ikate4) from the code listed bellow:

(If the commented CSS portion comes into effect, the output comes as expected)

<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Why is this?</title>
<style type="text/css">

.outter-box {
width: 900px;
/* border: 1px solid gray;*/
margin: auto;
background-color: gray;
}

.inner-box {
height: 300px;
width: 500px;
margin: 10px;
background-color: yellow;
}
</style>
</head>
<body>
<div class='outter-box'>
<div class='inner-box'>
</div>
</div>
</body>
</html>
 
Sheriff
Posts: 67637
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please UseCodeTags. Unformatted code is just too hard to read.
 
If we don't do the shopping, we won't have anything for dinner. And I've invited this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic