1

I've made a website where on the main div, multiple div's are displayed ( as inline-element's ) , those div's are containing an IMG and P element.

Well, if I leave the P element ( or text without p tag ), everything is ok, but if I add text after the img, the coresponding div will get out of the normal position.

The page is online at http://ace-acid.no-ip.org/acid-game-studios/ ( that is the working version )

And this one is the version with the problem in it -> http://ace-acid.no-ip.org/acid-game-studios-issue/ ( here you can clearly see that all the div's that have no text in it, are spaced downside... )

How can i prevent this behaviour ?

Thank you all guys ^^

< EDIT >

I think it's an css issue ( block element , inline-block element, fextflow, vertical align , ... ) isn't it ?

b.t.w. -> the website is a fluid grid based one, so if you scale down the browser, it will show a tabled and a mobile version. the problem seems to only apear in the same row where the text is, because in the next row, the div-blocks aren't spaced down...

< /EDIT >

HTML code:

<!doctype html>
<!--[if lt IE 7]> <html class="ie6 oldie"> <![endif]-->
<!--[if IE 7]>    <html class="ie7 oldie"> <![endif]-->
<!--[if IE 8]>    <html class="ie8 oldie"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="">
<!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>aCID Game Studios</title>
<link rel="stylesheet" type="text/css" href="boilerplate.css">
<link rel="stylesheet" type="text/css"href="style.css">
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<script src="respond.min.js"></script>
</head>
<body>
<div class="gridContainer clearfix">
    <div id="div_header" align="center">
        <div id="div_header_img"></div>
        <div id="div_menu" align="center">
            <p>&lt; MENU &gt;</p>
        </div>
    </div>
    <div id="div_main" align="center">
        <div id="div_page">
            <br><br><p>&lt; PAGE &gt;</p><br><br>
            <div class="div_game_thumb">
                <img style="vertical-align:middle" src="img/games/LegendOfAce.png" onMouseOver="this.src='img/games/LegendOfAce_hover.png'" onMouseOut="this.src='img/games/LegendOfAce.png'"/>
            </div>
            <div class="div_game_thumb">
                <img src="img/games/GunsOfTheNation.png" onMouseOver="this.src='img/games/GunsOfTheNation_hover.png'" onMouseOut="this.src='img/games/GunsOfTheNation.png'"/>
            </div>
            <div class="div_game_thumb">
                <img src="img/games/LegendOfAce.png" onMouseOver="this.src='img/games/LegendOfAce_hover.png'" onMouseOut="this.src='img/games/LegendOfAce.png'"/>
            </div>
            <div class="div_game_thumb">
                <img src="img/games/GunsOfTheNation.png" onMouseOver="this.src='img/games/GunsOfTheNation_hover.png'" onMouseOut="this.src='img/games/GunsOfTheNation.png'"/>
            </div>
            <div class="div_game_thumb">
                <img src="img/games/LegendOfAce.png" onMouseOver="this.src='img/games/LegendOfAce_hover.png'" onMouseOut="this.src='img/games/LegendOfAce.png'"/>
            </div>
        </div>
    </div>
</div>
</body>
</html>

CSS code:

@charset "utf-8";
/* Einfache fließende Medien
   Hinweis: Für fließende Medien müssen Sie die Attribute 'height' und 'width' des Medium aus dem HTML-Code entfernen
   http://www.alistapart.com/articles/fluid-images/ 
*/
html{
    margin: 0;
    padding: 0;
    border: 0;
}
body {
    background-color: #0c0d0f;
    color: #3982aa;
}
p {
    margin: 0;
    padding: 10px;
}
img, object, embed, video {
    width: 100%;
}
/* IE 6 unterstützt keine maximale Breite, verwenden Sie daher eine Standardbreite von 100% */
.ie6 img {
    width: 100%;
}
.div_game_thumb {
    width:320px;
    height:350px;
    display:inline-block;
    border:1px solid #fff;
}
/*
    Dreamweaver-Eigenschaften für fließende Raster
    ----------------------------------
    dw-num-cols-mobile:     6;
    dw-num-cols-tablet:     8;
    dw-num-cols-desktop:    14;
    dw-gutter-percentage:   15;

    Idee durch den Artikel "Responsive Web Design" von Ethan Marcotte 
    http://www.alistapart.com/articles/responsive-web-design

    und "Golden Grid System" von Joni Korpi
    http://goldengridsystem.com/
*/

/* Layout für Mobilgeräte: 480 px oder weniger. */

.gridContainer {
    margin-left: auto;
    margin-right: auto;
    width: 100%;
    padding-left: 0;
    padding-right: 0;
}
#div_header {
    clear: both;
    float: left;
    margin: 0;
    width: 100%;
    display: block;
}
#div_header_img {
    width: 450px;
    height: 150px;
    background-color: #999;
    background-position: top center;
    background-repeat: no-repeat;
    background-image: url(img/header_m.png);
}
#div_menu {
    width: 450px;
    height: 50px;
    background-color: #111;
}
#div_main {
    clear: both;
    float: left;
    margin: 0;
    width: 100%;
    display: block;
    min-height: 300px;
}
#div_page {
    width: 450px;
    min-height: 300px;
    background-position: top center;
    background-repeat: repeat-x;
    background-image: url(img/page_border_top.png);
    background-color: #000;
}

/* Layout für Tablet-PCs: 481 bis 768 px. Erbt Stile vom: Layout für Mobilgeräte. */

@media only screen and (min-width: 481px) {
    body {
        background-position: top center;
        background-repeat: repeat;
        background-image: url(img/bg.png);
    }
    #div_header {
        clear: both;
        float: left;
        width: 100%;
        display: block;
        display: block;
        background-position: top center;
        background-repeat: repeat-y;
        background-image: url(img/page_bg_t.png);
    }
    #div_header_img {
        width: 650px;
        height: 150px;
        display: block;
        background-image: url(img/header_t.png);
    }
    #div_menu {
        width: 650px;
        background-position: top center;
        background-repeat: no-repeat;
        background-image: url(img/menu_bg_t.png);
    }
    #div_main {
        clear: both;
        float: left;
        margin: 0;
        width: 100%;
        display: block;
        background-position: top center;
        background-repeat: repeat-y;
        background-image: url(img/page_bg_t.png);
    }
    #div_page {
        width: 650px;
    }
}

/* Desktoplayout: 769 bis maximal 1232 px.  Erbt Stile von: den Layouts für Mobilgeräte und Tablet-PCs. */

@media only screen and (min-width: 769px) {
    #div_header {
        clear: both;
        float: left;
        width: 100%;
        display: block;
        background-image: url(img/page_bg.png);
    }
    #div_header_img {
        width: 1000px;
        height: 200px;
        background-image: url(img/header.png);
    }
    #div_menu {
        width: 1000px;
        background-position: top center;
        background-repeat: no-repeat;
        background-image: url(img/menu_bg.png);
    }
    #div_main {
        clear: both;
        float: left;
        margin: 0;
        width: 100%;
        display: block;
        background-image: url(img/page_bg.png);
    }
    #div_page {
        width: 1000px;
    }
}

2 Answers 2

1

Use vertical-align: top; on .div_game_thumb

Inline elements obey to vertical alignment.

Also, if you want cross-browser inline-blocks (IE7+) you need to define it like this:

display: inline-block;
*zoom: 1;
*display: inline;

*Note: The order is important.

Sign up to request clarification or add additional context in comments.

Comments

0

vertical-align: top saves the day! Put it on .div_game_thumb.

You can restore the little bit of margin that disappears after doing this by adding margin: 2px 0; as well.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.