html - 将多个 div 对齐

标签 html css alignment

有没有一种方法可以将 4 个 div 对齐在一起,以便它们都整齐地内联,我在一个 div 中有一个图像,在另一个 div 中有一个标题,在其他单独的 div 中有文本和另一个图像,但我希望它们看起来都一致.参见 fiddle

<div id="christmas_product_boxes">
    <div id="christmas_mattress">
        <img src="http://blog.applause.com/wp-content/uploads/2013/05/one_star.jpg" height="100px" width="100px">
    </div>
    <div id="christmas_pillows">
        <img src="http://blog.applause.com/wp-content/uploads/2013/05/one_star.jpg" height="100px" width="100px">
    </div>
    <div id="christmas_beds">
        <img src="http://blog.applause.com/wp-content/uploads/2013/05/one_star.jpg" height="100px" width="100px">
    </div>
</div>
<br>
<br>
<div id="christmas_product_boxes_title">
    <div id="christmas_mattress_title">
        <h2>Title 1</h2>
    </div>
    <div id="christmas_pillow_title">
        <h2>Title 2</h2>
    </div>
    <div id="christmas_beds_title">
        <h2>Title 3</h2>
    </div>
</div>
<div id="christmas_product_boxes_text">
    <div id="christmas_mattress_text">
        <p>This is some text in a p tag!! <br>This is some text in a p tag!! <br>This is some text in a p tag!!</p>
    </div>
    <div id="christmas_pillow_text">
        <p>This is some text in a p tag!! <br>This is some text in a p tag!! <br>This is some text in a p tag!!</p>
    </div>
    <div id="christmas_beds_text">
        <p>This is some text in a p tag!! <br>This is some text in a p tag!! <br>This is some text in a p tag!!</p>
    </div>
</div>
<div id="christmas_product_boxes_buttons">
    <div id="christmas_mattress_button">
        <a href="#"><img src="http://www.downloadclipart.net/large/253-button-blue-design.png" height="30px" width="30px"></a>
    </div>
    <div id="christmas_pillow_button">
        <a href="#"><img src="http://www.downloadclipart.net/large/253-button-blue-design.png" height="30px" width="30px"></a>
    </div>
    <div id="christmas_beds_button">
        <a href="#"><img src="http://www.downloadclipart.net/large/253-button-blue-design.png" height="30px" width="30px"></a>
    </div>
</div>

最佳答案

这样的事情怎么样:

fiddle :http://jsfiddle.net/6Lrdp/1/

按照 fiddle 将这些样式应用于大多数容器。

width: 130px;
margin:0 10px 0 50px
text-align: center;

您将不得不弄乱尺寸。 . .

关于html - 将多个 div 对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19707231/

相关文章:

html - 谷歌地图信息窗口显示在左上角

html - 用重复的线性渐变改变颜色

javascript - 如何检查鼠标光标是否超过某个 x 坐标?

c++ - 为什么编译器会提示对齐?

html - Bootstrap 中的列对齐

javascript - 正则表达式转义 HTML 标签

html - 如何从输入中删除黑色顶部和左侧轮廓

javascript - 如何通过 jQuery 混合使用数字和其他 div 高度来设置 div 的高度?

html - 如何对齐电子邮件字段旁边的订阅按钮?

r - 如何在 R 中执行基本的多序列比对?