简体   繁体   English

在div内对齐图像

[英]Aligning images inside divs

I'm trying to fit three images inside a div, but I'm having trouble getting them to align properly. 我正在尝试在一个div中容纳三个图像,但是我很难使它们正确对齐。 This is what I have in mind: 这就是我的想法:

alt text http://img245.imageshack.us/img245/2016/divsf.jpg 替代文字http://img245.imageshack.us/img245/2016/divsf.jpg

But I can't for the life of me figure this one out. 但是我无法为我的生命解决这一问题。 Can anyone please lend a hand? 有人可以帮忙吗? Thanks! 谢谢!

如果允许更改标记,我建议将img 1和img包装在另一个div中-这只是将div浮动到左侧的问题。

CSS 的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 的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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM