主要用到的知识点是:css 样式里的 多列布局:columns 和 column-gap
column-count | 指定元素应该分为几列 |
column-fill | 指定如何填充每个列 |
column-gap | 指定列与列之间的间隙 |
column-rule | 所有 column-rule-* 属性的简写形式 |
column-rule-color | 指定列与列之间边框的颜色 |
column-rule-style | 指定列与列之间边框的样式 |
column-rule-width | 指定列与列之间边框的宽度 |
column-span | 指定元素应该横跨多少列 |
column-width | 指定列的宽度 |
columns | column-width 与 column-count 属性的简写属性 |
<article dangerouslySetInnerHTML={{__html: `${detail || ''}<div id="end"></div>`}}>
</article>
<div id="end"></div> 这个是要加的 通过end的偏移量来计算页数
const article = document.querySelector('article');
const width = document.body.offsetWidth;
let offsetLeft = document.getElementById('end').offsetLeft; // end 的向左偏移量
const maxPage = utils.caculate.accDiv(offsetLeft, width); // 相当于 offsetLeft / width
if(currentPage < maxPage){ // currentPage 当前页码
// 通过 article.style.transform 水平移动 来控制展示第几页
article.style.transform = `translateX(-${utils.caculate.accMul(width, currentPage + 1)}px)`;
setCurrentPage(currentPage + 1)
}
article{
columns: calc(100vw - 32px) 1;
column-gap: 32px;
height: 100%;
line-height: 1.5;
p:not(:has(img)){
text-indent: 2em;
}
img {
max-width: calc(100vw - 32px);
max-height: 100%;
}
}