I have some relatively positioned inline-block
elements side-by-side within a parent, and I've applied a margin:0
to all children of the parent, but they still have some space in between them. What's happening here?
#parent {
height: 100px;
}
#parent * {
margin: 0;
}
#parent div {
display: inline-block;
position: relative;
border: 1px solid red;
width: 50px;
height: 100%;
}
<div id="parent">
<div></div>
<div></div>
<div></div>
</div>
You have white space between your inline-block elements. If you have 100% control over your DOM, make sure there is absolutely no white space between your markup. If you don't have control over it, you can use a little workaround by doing the following:
Here is a fiddle to demonstrate:
http://jsfiddle.net/ucuzpb4d/
Here is the fiddle with no white-space: http://jsfiddle.net/ucuzpb4d/1/