当class列表中,对齐类在缩进类之后时,对齐样式就会失效!
.align-center{
text-align: center;
}
.indent-1 {
margin-left: 4em;
}
生效:
<p class="align-center indent-1">居中对齐</p>
失效:
<p class="indent-1 align-center">居中对齐</p>
改变class列表顺序代码:
document.write(`
<ol>
<li>
<strong style="color: rgb(32, 33, 36)">字体加粗</strong><em style="color: rgb(32, 33, 36)">字体倾斜</em><u
style="color: rgb(32, 33, 36)">下划线</u><s style="color: rgb(32, 33, 36)">中划线</s><span class="size-huge"
style="color: rgb(32, 33, 36)">HUge字号</span><span style="color: rgb(32, 33, 36)"
class="size-large">Large字号</span><span style="color: rgb(32, 33, 36)">Normal字号</span><span
style="color: rgb(32, 33, 36)" class="size-small">Small字号</span><span style="color: rgb(32, 33, 36)"
class="font-default">Def字体</span><span style="color: rgb(32, 33, 36)" class="font-serif">Ser字体</span><span
style="color: rgb(32, 33, 36)" class="font-sansserif">San字体</span><span style="color: rgb(32, 33, 36)"
class="font-bebas">Beb字体</span><span style="color: rgb(32, 33, 36)" class="font-QingflowFont">字体</span><span
style="color: rgb(230, 0, 0)">字体颜色</span><span style="color: rgb(0, 102, 204)">字体</span><span
style="color: rgb(0, 71, 178)">颜色</span><span
style="color: rgb(0, 71, 178); background-color: rgb(230, 0, 0)">填充</span><span
style="color: rgb(32, 33, 36); background-color: rgb(230, 0, 0)">颜色</span><span
style="color: rgb(32, 33, 36); background-color: rgb(102, 163, 224)">填充验收 </span><span
style="color: rgb(32, 33, 36)">有序号排列</span>
</li>
<li><span style="color: rgb(32, 33, 36)">有序号排列</span></li>
</ol>
<ul>
<li><span style="color: rgb(32, 33, 36)">无序号排列</span></li>
<li><span style="color: rgb(32, 33, 36)">无序号排列</span></li>
</ul>
<blockquote><span style="color: rgb(32, 33, 36)">分段符</span></blockquote>
<p class="indent-1"><span style="color: rgb(32, 33, 36)">首行缩进</span></p>
<p class="indent-1"><span style="color: rgb(32, 33, 36)">左对齐方式</span></p>
<p class="indent-1 align-center">居中对齐</p>
<p class="indent-1 align-center">
<span style="color: rgb(32, 33, 36)">右对齐方式</span>
</p>
<p class="indent-1 align-center">
<span style="color: rgb(32, 33, 36)">平</span>
<span style="color: rgb(32, 33, 36)">铺</span>
<span style="color: rgb(32, 33, 36)">对</span>
<span style="color: rgb(32, 33, 36)">齐</span>
<span style="color: rgb(32, 33, 36)">方</span>
<span style="color: rgb(32, 33, 36)">式</span>
</p>
<p class="indent-1 align-center">
<a href="#" rel="noopener noreferrer" target="_blank" style="color: rgb(32, 33, 36)">超链接</a>
</p>
<p><img src="" width="289" /></p>
<p>hello!</p>
`)
let visted = []
function dfs2(node) {
// debugger;
if (visted.includes(node)) {
return
}
visted.push(node)
// 当前层逻辑
// console.log(node)
if (node.className.match(/.*align-.*/)) {
console.log(node.className)
debugger ;let temp = 'indent-1 align-center'.split(' ');
let left = [];
let right = [];
for (let item of temp) {
if (item.match(/align-.*/)) {
left.push(item)
} else {
right.push(item)
}
}
node.className = [...left, ...right].join(' ');
}
let children = [...node.children]
for (let next_node of children) {
if (next_node && !visted.includes(next_node)) {
dfs2(next_node)
}
}
}
dfs2(document.body)
dfs2(document.body)
或者将所有样式均转成行内
outlook客户端不强制使用**word-break: break-all**
就不会自动换行,最好加上这个样式。