我需要像这样显示两张图片和一些文字:
------------------------------------------ img1--------some centered text-------img2 ------------------------------------------
- img1 和 img2 尺寸不一样,但宽度很接近
- 文本根据显示的页面而变化,可能包含两行而不是一行。
- 文本需要在两个图像之间水平居中,或者在容器外部之间(两者都可以)
- 文本和图像需要在容器内垂直居中。
我可以使用表格非常轻松地完成此操作,但我不想退回到表格布局。 position:inline-block
和 display:table-cell
属性在某些浏览器中效果很好,但我需要支持 IE6+。
最佳答案
<style type="text/css">
#image1 { float: left; }
#image2 { float: right; }
#text { text-align: center; }
</style>
关于CSS 在两个图像之间居中文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3008612/