情況如下:我想將嵌套的 DIV 元素更改為表格元素,我希望將類設(shè)置為內(nèi)聯(lián)樣式。我現(xiàn)在有一個包含類和樣式屬性的示例數(shù)組:$classes = array( 'container' => 'width: 100%;padding-right: 15px;padding-left: 15px;margin-right: auto;margin-left: auto;', 'card' => 'position: relative;display: -ms-flexbox;display: flex;-ms-flex-direction: column;flex-direction: column;min-width: 0;word-wrap: break-word;background-color: #fff;background-clip: border-box;border: 1px solid rgba(0, 0, 0, 0.125);border-radius: 0.25rem;', );然后將此代碼轉(zhuǎn)換為以下內(nèi)容:<div class="container"> 01 <div class="card"> 02 </div></div>然后將從此代碼創(chuàng)建此代碼:<table> <tr> <td class="container" style="width: 100%;padding-right: 15px;padding-left: 15px;margin-right: auto;margin-left: auto;"> 01 <table> <tr> <td class="card" style="position: relative;display: -ms-flexbox;display: flex;-ms-flex-direction: column;flex-direction: column;min-width: 0;word-wrap: break-word;background-color: #fff;background-clip: border-box;border: 1px solid rgba(0, 0, 0, 0.125);border-radius: 0.25rem;"> 02 </td> </tr> </table> </td> </tr></table>有誰知道我怎么能做這樣的事情?自周五以來,我一直在試驗(yàn) preg_replace_callback 和 DOMDocument。不幸的是一切都沒有成功。
- 1 回答
- 0 關(guān)注
- 123 瀏覽
添加回答
舉報
0/150
提交
取消