4

Something strange happening... I am using display: inline-block to show elements inline. There was all ok until add added some new elements in it. Here is an examples:

god bad

CSS:

section#main{
    width: 960px;
    margin: 7% auto 0;
    background: #000;
    opacity: 0.86;
    -webkit-border-radius: 5px;
    -moz-border-radius: 5px;
    border-radius: 5px;
    padding: 5px;
}

div#video{
    border: 1px solid red;
    width: 640px;
    height: 360px;
    margin: 10px;
    display: inline-block; 
}

nav{
    margin: 10px;
    border: 1px solid yellow;
    display: inline-block;
    height: 360px;
    width: 270px;
}

HTML:

<section id="main">
        <div id="video"></div>
        <nav>
            <ul>
            <li>Keliaujame ?... JAV: ?ikaga / Chicago S01E03</li>           
            </ul>
        </nav>
        <div id="comments"></div>
    </section>

http://jsfiddle.net/nonamez/PfeP5/2/

What could be wrong?

user1692333
  • 2,461
  • 5
  • 32
  • 64

3 Answers3

4

That's a vertical alignment issue, just set both elements vertical alignment to top

div#video{
    vertical-align:top;
}

nav{
    vertical-align:top;
}

http://jsfiddle.net/xHNJm/

Musa
  • 96,336
  • 17
  • 118
  • 137
1

remove display: inline-block; from both

add float: left; to both

add a <div style="clear: both"></div> below the <div id="comments">

as demonstrated in this fiddle: http://jsfiddle.net/9BsS3/

fizzy drink
  • 682
  • 8
  • 21
0

Personally, I always try to avoid using inline-block, just because of the ropey behaviour cross-browser.

I would use the following CSS (removing the display:inline-block; and use float:left in it's place (ensuring the parent element is also floated to ensure the clearing of child floated elements):

section#main{
    width: 960px;
    margin: 7% auto 0;
    float:left;
    background: #000;
    opacity: 0.86;
    -webkit-border-radius: 5px;
    -moz-border-radius: 5px;
    border-radius: 5px;
    padding: 5px;
}

div#video{
    border: 1px solid red;
    width: 640px;
    height: 360px;
    margin: 10px;
    float:left;
}

nav{
    margin: 10px;
    border: 1px solid yellow;
    float:left;
    height: 360px;
    width: 270px;
}
nav ul {
    margin:0;
    padding:0;
    list-style:none;
}
nav li {
    color:#fff;
}
seemly
  • 1,090
  • 10
  • 20