html - 固定 2 列内的内容

标签 html css

我正在尝试从 HTML 生成 PDF,我已经能够做到,但是我在正确设置 HTML 列时遇到了问题。

我有 2 个名为 ab 的列,请参阅代码:

.a{
    background: red;
    width: 24%;
    display: inline-block;
    padding: 5px;
  }

 .b{
    background: blue;
    width: 74%;
    display: inline-block;
    padding: 5px;
  }

A 列将包含 5 个图标,B 列将包含文本、标题等。我遇到的问题是 A 列中的图像根据 B 列中输入的数据量移动,并且反之亦然。

我想修复两列中的内容,因此无论在 B 列中输入多少文本,图标都会保持不变。

下图显示了我得到的输出:

大量文本

enter image description here

少量文本

enter image description here

如果我没有正确解释,请道歉,请告诉我,我会尽力解释得更好。

最佳答案

默认情况下,inline-block 元素有vertical-align: baseline。如果您希望列在顶部对齐,请在列上使用 vertical-align: top

.a {
  background: red;
  width: 25%; 
}

.b {
  background: blue;
  width: 75%;
}

.a, .b {
  vertical-align: top;
  display: inline-block;
  padding: 5px;
  box-sizing: border-box;
}

img {
  max-width: 100%;
}
<div class="a">
  <img src="/image/2C22p.jpg"><img src="/image/2C22p.jpg"><img src="/image/2C22p.jpg"><img src="/image/2C22p.jpg"><img src="/image/2C22p.jpg"><img src="/image/2C22p.jpg"><img src="/image/2C22p.jpg"><img
    src="/image/2C22p.jpg"><img src="/image/2C22p.jpg"><img src="/image/2C22p.jpg">
</div><!--
--><div class="b">Column A would contain 5 icons and Column B would contain Text, Heading etc. The issue I am having is that the images in Columns A move based on the amount of data entered in Column B and vice versa.

  <br>Column A would contain 5 icons and Column B would contain Text, Heading etc. The issue I am having is that the images in Columns A move based on the amount of data entered in Column B and vice versa.

  <br>Column A would contain 5 icons and Column B would contain Text, Heading etc. The issue I am having is that the images in Columns A move based on the amount of data entered in Column B and vice versa.

  <br>Column A would contain 5 icons and Column B would contain Text, Heading etc. The issue I am having is that the images in Columns A move based on the amount of data entered in Column B and vice versa.

  <br>Column A would contain 5 icons and Column B would contain Text, Heading etc. The issue I am having is that the images in Columns A move based on the amount of data entered in Column B and vice versa.

  <br>Column A would contain 5 icons and Column B would contain Text, Heading etc. The issue I am having is that the images in Columns A move based on the amount of data entered in Column B and vice versa.

  <br>Column A would contain 5 icons and Column B would contain Text, Heading etc. The issue I am having is that the images in Columns A move based on the amount of data entered in Column B and vice versa.

  <br>Column A would contain 5 icons and Column B would contain Text, Heading etc. The issue I am having is that the images in Columns A move based on the amount of data entered in Column B and vice versa.

  <br>Column A would contain 5 icons and Column B would contain Text, Heading etc. The issue I am having is that the images in Columns A move based on the amount of data entered in Column B and vice versa.

  <br>
</div>

关于html - 固定 2 列内的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44806180/

相关文章:

php - 直接将 CSV 文件下载到用户下载文件夹

javascript - 无法在 HTML5 中运行 cocos2d javascript sprite 的 Ripple3D 操作

html - Chrome 嵌入式 PDF 下载文件名

html - 在 bootstrap3.0 中修复鼠标悬停打开的菜单后,当我们点击 menuitem 时菜单没有关闭它保持打开状态

javascript - 如何在所选内容中间的文本突出显示上显示弹出窗口?

javascript - 将 <button> 标签放在 <span> 标签内是正确的放置方式

html - 更改 Bootstrap Navbar 的默认背景颜色

html - 如何修复标题标题太长时消失的 CSS 选项卡

html - Chrome 打印表格,有些行的高度是随机的?

javascript - JQuery 获取 IFrame 中的父 URL :iframe and its parent are in Different domain