css - 图像根据其下方的文本移动

标签 css

为什么我的图像会根据图像下方的内容移动?我对每个描述都有不同数量的文本,但图像会根据行数来回移动?

 <div>
      <img src="img">
      <p>one line</p>
 </div>
 <div>
      <img src="img">
      <p>two lines of text</p>
 </div>




 <style>
     div {
          display:inline-block;
          width:150px;
          text-align:center;
     }
     img {
        display:block;
        margin:0 auto;
     }
     p {
        padding-top:10px;
      }
  </style>

最佳答案

我需要一个 float:left 而不是使用内联。

关于css - 图像根据其下方的文本移动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21272889/

相关文章:

php - 在单个请求中组合 CSS

javascript - Jquery 或 CSS : Set static, div 的高度不可更改?

css - 给表格单元格相同的高度

javascript - 将 FormPanel 放入 RowExpander 中?

javascript - jQuery,从左到右缩小div宽度

css - 如何在 Webpack 4 中启用 SASS 模块

html - Internet Explorer 中的按钮上出现奇怪的白线

javascript - 当我在 IIS7 中托管应用程序时,CSS 和 Javascripts 未加载

CSS 放置示例(标题、图像、文本和阅读更多链接)

html - 切换 CSS 在 Internet Explorer 中不起作用