1 reply [Last post]
gautamz07
gautamz07's picture
Offline
Enthusiast
Last seen: 3 years 45 weeks ago
Timezone: GMT+5.5
Joined: 2014-04-24
Posts: 265
Points: 403

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>hidden demo</title>
  <style>
  div {
    width: 70px;
    height: 40px;
    background: #e7f;
    margin: 5px;
    display: inline-block;
  }
 
  </style>
  <script src="js/jquery.min.js"></script>
</head>
<body>
 
<div>hello</div>
<div></div>
<div></div>
<div></div>
<div></div>
 
 
</body>
</html>

if why the 1st div move down ?? when i do display:inline-block and enter some word inside the div ??

also if i remove display:inline-block and instead use float:left , everything sits up just perfect .

gary.turner
gary.turner's picture
Offline
Moderator
Dallas
Last seen: 22 hours 32 min ago
Dallas
Timezone: GMT-5
Joined: 2004-06-25
Posts: 9761
Points: 3843

Not tested

I suspect margin collapse may be involved. You didn't say in which browser/s you're testing.

See Uncollapsing margins.

cheers,

gary

If your web page is as clever as you can make it, it's probably too clever for you to debug or maintain.