Force float left with no line break no matter what

放肆的年华 提交于 2019-12-13 13:16:34

问题


I'm guessing this isn't possible, but here goes.

I have two tables, and I'm trying to get them to sit side-by-side so that they look like one table. The reason for this, instead of using one larger table, is that the data in the second table needs to be handled on a column basis, not row basis, for performance reasons like caching and AJAX-fetching data. So rather than have to reload the whole table for a single column, I decided to break the column out into a separate table, but have it visually seem like a single table.

I can't find a way to forcibly put the second table next to the first. I can float them, but when the first table is too wide, the second one breaks to the next line. Here's the kicker: the width of the first table is dynamic. So I can't just set a huge width to their container. Well, I could set a huge width, like 1000%, but then I have a huge ugly horizontal scroll bar.

So is there any way to tell the second table "Stay on that same line, no matter what! And line up right next to the previous element please!"


回答1:


Put your two tables in another table with a single row and two cells. Not elegant or 'modern' but it will work.




回答2:


If your table is one table, you should have sticked with one table.

You are trying to fix a data manipulation issue by using a different document structure.

Using a different class per column with the DOM navigation tools provided by library such as jquery, you should not have any problem accessing cells or columns you want to update.

I would not go the route you chose.




回答3:


How about this:

<div>
<div class=lspacer>
<table1>
</table1>
</div>
<div class=rspacer>
<table2>
</table2>
</div>
</div>

Then, for lspacer, you can clear it left, and for rspacer, you can clear it right. Also, you specify the width.



来源:https://stackoverflow.com/questions/2556250/force-float-left-with-no-line-break-no-matter-what

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!