对齐div中的图像

时间:2010-07-29 13:42:31

标签: css html image

我正在尝试在div中放入三个图像,但是我无法让它们正确对齐。这就是我的想法:

alt text http://img245.imageshack.us/img245/2016/divsf.jpg

但是我不能为我的生活把这一点弄清楚。任何人都可以伸出援助之手吗?谢谢!

3 个答案:

答案 0 :(得分:1)

答案 1 :(得分:0)

如果允许更改标记,我建议将img 1和2包装在另一个div中 - 那么只需将div浮动到左边。

答案 2 :(得分:0)

<强> CSS

div#container {
    width:400px;
    height: 400px;
    padding:50px;
    background: red;
}
div.leftbox {
    float: left;
    width:175px;
    height: 175px;
    margin-bottom: 50px;
    background: blue;
}
div.rightbox {
    float: right;
    width: 175px;
    height: 400px;
    background: yellow;
}

<强> HTML

<div id="container">
    <div class="rightbox">
        Right Image Box
    </div>
    <div class="leftbox">
        Left Image Box Top
    </div>
    <div class="leftbox">
        Left Image Box Bottom
    </div>
</div>
相关问题