简体   繁体   English

将所有 DIV 元素更改为 TABLE、TR、TD 及其属性

[英]Change all DIV elements to TABLE, TR, TD with its attributes

I have a code completely written with DIV based structure.我有一个完全用基于 DIV 的结构编写的代码。 There is a problem with this div based structure when it is rendered in EMAIL.这种基于 div 的结构在 EMAIL 中呈现时存在问题。 The alignment is not the same in all EMAIL clients.并非所有 EMAIL 客户端的对齐方式都相同。 So I was trying to convert all the DIV based structure to TABLE structure.所以我试图将所有基于 DIV 的结构转换为 TABLE 结构。

Here goes the actual code这是实际的代码

<div class="layoutContainer" style="width: 880px; height: 700px; background: rgb(255, 255, 255);">
    <div class="contentInside" style="transform: translate(0px, 0px); width: 260px; left: 0px; top: 0px;">
        test content1
    </div>
    <div class="contentInside" style="transform: translate(-375px, 0px); width: 394px; left: 399px; top: 0px;">
        test content2
    </div>
</div>

I expect the above code to get converted as below我希望上面的代码得到如下转换

<table class="layoutContainer" style="width: 880px; height: 700px; background: rgb(255, 255, 255);">
    <tr> 
        <td>
            <table class="contentInside" style="transform: translate(0px, 0px); width: 260px; left: 0px; top: 0px;">
                <tr>
                    <td>
                        test content1
                    </td>
                </tr>
            </table>
            <table class="contentInside" style="transform: translate(-375px, 0px); width: 394px; left: 399px; top: 0px;">
                <tr>
                    <td>
                        test content2
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>

Can someone please help me in this.有人可以帮助我吗?

You can let the div element behave like table using css.您可以使用 css 让 div 元素表现得像 table。
display:table -for table display:table - 用于表
display:table-cell -for column display:table-cell -for 列
display:table-row -for row display:table-row -for row

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM