是否可以通过编程将基于 CSS div 的布局转换为表格布局?

发布于 2024-11-18 12:17:14 字数 304 浏览 2 评论 0原文

我们有一位自由设计师进来,用 HTML 和 CSS(基于 div)为我们构建了一个很棒的内部 Web 应用程序。然而,对于我们内部系统的一部分,我们有一个遗留系统,它在渲染方面存在问题,并且它需要一个具有适当样式的表格布局结构才能工作。

我们无法手动转换内容,因为页面太多,需要很长时间。

所以我将尝试以编程方式完成此操作。在开始之前,这可能吗?我应该考虑什么吗?也许有人已经这样做了?

我将使用 PHP 及其 DOM Document 类 - 好主意吗?

我真的需要这方面的帮助,因为我们可能在这个项目上浪费了大量的金钱和时间。

We've had a designer come in on a freelance basis to build us an awesome internal web app in HTML and CSS (div based). However, for part of our internal system we have a legacy system which has problems rendering this and it needs a table layout structure with appropriate styling for it to work.

We can't convert things manually because it will take too long as there are lots and lots of pages.

So I am going to attempt to do this programmatically. Before I start, is this possible? Are there any consideration I should think about? Maybe someone has done this already?

I'll be using PHP and its DOM Document class - good idea?

I really need help on this as we might have wasted a lot of money and time on this project.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

你是暖光i 2024-11-25 12:17:14

例如,可以以编程方式适应特定情况,从页面中提取数据并将其插入到不同的模板中。

不过,您将无法为一般情况编写一些内容。 CSS 的工作方式与上个世纪的表格布局完全不同。

我会考虑改进过时的渲染器。

It might be possible to programatically adapt a specific case, pulling data out of a page and inserting it into a different template, for instance.

You won't be able to write something for the general case though. CSS works in a completely different way to the table layouts of the last millenium.

I'd look at getting the out of date renderer improved instead.

伏妖词 2024-11-25 12:17:14

您的新站点是否可以简单地封装在表格中,而不是完全重写以在各处使用表格?如果表格是您网站的宽度,只需将整个现有 HTML 放入单个表格单元格中即可。

如果做不到这一点,在 iframe 内交付新网站不会(不应该)太难,尽管您可能需要一些跨框架通信来根据内容动态调整 iframe 的高度(因此您可以避免页面内的滚动条)。

我必须同意其他人的观点——以编程方式将代码从语义转换为 tablemush 至少会带来很大的问题,而且充其量也只能部分成功。手工完成可能会更快。

Could your new site simply be wrapped in a table instead of completely rewritten to use tables everywhere? If the table is the width of your site, just put the whole existing HTML inside a single table cell.

Failing that, it wouldn't (shouldn't) be overly hard to deliver the new site inside an iframe instead, although you might need some cross-frame communication for dynamically adjusting the height of the iframe based on the content (so you avoid scroll bars within the page).

I have to agree with everyone else - programmatically converting the code from semantic to tablemush would be, at the very least, hugely problematic and only partially successful at best. It would probably be faster to just do it by hand.

夜空下最亮的亮点 2024-11-25 12:17:14

如果基于 div 的 HTML 是正确生成的,并且遵循类似表格的布局,例如:

<div class="table">
    <div class="row>
        <div class="cell">...</div>
        <div class="cell">...</div>
    </div>
</div>

那么使用一些 DOM 操作将各个单元格转换为直接基于表格的等效项就不会太难。但是,如果 html 很糟糕,不符合逻辑顺序,等等...那么您就会陷入痛苦的境地,最好修改代码以从一开始就输出表格。

If the div-based HTML is sanely generated, and follows a table-like layout, something like:

<div class="table">
    <div class="row>
        <div class="cell">...</div>
        <div class="cell">...</div>
    </div>
</div>

then it wouldn't be too hard to use some DOM manipulations to transform the individual cells into their direct table-based equivalents. However, if the html is nasty, not in logical order, etc... then you're in for a world of hurt and it'd be better to modify the code to output a table from the get-go.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文