Css未能并排列出框

时间:2012-12-10 08:27:51

标签: html css

我有一个简单的代码,我想在图库中列出图像。我想显示我的图像

然而,div在y轴上以升序输出。我怎样才能解决这个问题?我的php和html代码在这里

<div id="gallerycontent">
        <?php for($x=0;$x<10; $x++){ ?>
        <div class="galleryitem">
        <img src="images/SamplePackSpread.png"/>
        </div>
        <?php }?>
    </div>

我的css代码在这里

#gallerycontent{
    float: left;
    max-width: 685px;
    padding: 10px 5px 5px 5px;
    text-align: justify;
}

#gallerycontent .galleryitem{
    width: 250px;
    height: 250px;
    background:url('../images/screen.png');
    background-repeat: no-repeat;
    padding: 5px 5px 5px 5px;
    -moz-border-radius: 5px;
    -webkit-border-radius: 5px;
    border-radius: 5px;
    clear: both;
}
#gallerycontent img{
    float: left;
    width: 90%;
    height: 90%;
    margin: 2.5%;
}
#gallerycontent ul{
    padding-left: 50px;
    list-style-type:square;
}

1 个答案:

答案 0 :(得分:2)

display:inline-block添加到.galleryitem

#gallerycontent .galleryitem{
    width: 250px;
    height: 250px;
    background:url('../images/screen.png');
    background-repeat: no-repeat;
    padding: 5px 5px 5px 5px;
    -moz-border-radius: 5px;
    -webkit-border-radius: 5px;
    border-radius: 5px;
    clear: both; display:inline-block
}

<强> DEMO