1

如何让我的 DIV 的内容都保持在一条线上?我看过其他帖子,但我可以弄清楚我做错了什么?

这是一个有问题的页面的链接: http ://www.heatx.org/productcart/pc/viewCategories.asp?idCategory=2

4

4 回答 4

0

请将此添加到您的css文件底部

table{
margin: 0 auto;
}

使您的网站居中对齐

你的菜单没有出现!

于 2013-05-24T18:36:34.667 回答
0

我相信问题是由于 div 内的图像造成的。设置display:inline为那些图像。

于 2013-05-24T18:17:52.723 回答
0

给定您的链接,首先添加float: left;to#pcIconBarRight img#pcIconBar a。这应该解决您的问题。

编辑:

然后改变这个:

在此处输入图像描述

和这个: 在此处输入图像描述

EDIT2:要在一行中显示两个 div,您可以这样做:

<div style="float: left; width: 200px;">
    <div style="float: left; clear: none;">Total:&nbsp;</div>
    <div style="float: left; clear: none;">159 USD</div>
</div>

注意:width: 200px;您应该将宽度设置为足够大以适应内部 div,否则它会将第二个 div 打断到下一行。

于 2013-05-24T18:18:02.017 回答
0

回答OP的问题有点晚了。这对其他有同样问题的人很有用。

因此,要让所有元素出现在一行上,最简单的方法是:

  1. 设置空白:nowrap;溢出-x:自动;在父元素上。
  2. 在所有子元素上设置display: inline-block 。

结果: 在此处输入图像描述

小提琴

 <div style="width:100%;white-space:nowrap;overflow-x:auto;border: 1px solid red; border-radius: 10px;padding: 3px;">
   <label style="display: inline-block">Some label </label>
  <select style="display: inline-block">
    <option value="0">aaaaa</option>
    <option value="1">bbbbbb</option>
    <option value="2">ccccccccc</option>
  </select>
  <label style="display: inline-block">Another label: </label>
  <input type="text" style="display: inline-block;width:200px;" />
  <span style="display: inline-block">NOTE: some other text</span>
</div>
于 2018-09-05T09:02:35.437 回答