-1

http://jsfiddle.net/6CQUT/

In the example above, logo has a right margin and I can't put menu near it without resizing it(it should be 100x100) or it being pushed under it. Where did the margin came from and how can I get rid of it?

Code as requested.

<body>
    <div id="header">
        <div id="logo">logo</div>
        <div id="menu">menu</div>
    </div>
    <div id="cont">under</div>
</body>


#header {
    width:200px;
    height:100px;
    outline:solid 1px black;
}
#logo {  display:inline-block;
    width:100px;
    height:100px;
    outline:solid 1px black;
}
#menu {
    display:inline-block;
    width:96px;
    height:96px;
    outline:solid 1px black;
}
#cont {
    outline:solid 1px black;
    width:200px;
    height:300px;
}
George Irimiciuc
  • 4,573
  • 8
  • 44
  • 88

3 Answers3

2

As i mentionned in my comments, you are dealing with white-space coming from your HTML code when set element as inline-boxes.

There s many ways, and one example provided was to remove it from code . logo</div><div id="menu" as shown here : http://jsfiddle.net/6CQUT/2/

But the best, i guess is to link to some tutorials to understand what is going on (links picked up from a search engine :) ):

http://css-tricks.com/fighting-the-space-between-inline-block-elements/

http://davidwalsh.name/remove-whitespace-inline-block

How to remove the space between inline-block elements?

Community
  • 1
  • 1
G-Cyrillus
  • 101,410
  • 14
  • 105
  • 129
1

One option is to keep display: inline-block and add this: http://codepen.io/pageaffairs/pen/fKkbE

#header {
  word-spacing:-.25em; /* hide whitespace nodes in all modern browsers (not for webkit)*/
  display:table;/* Webkit Fix */
}

#header div {
  word-spacing:0; /* reset from parent*/
}
ralph.m
  • 13,468
  • 3
  • 23
  • 30
0

I had the same issue. In the css margin: -2px; seemed to solve it for me.

Joe Giusti
  • 159
  • 1
  • 3