有没有一种方法可以将 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/