const button = document.createElement("button");
const icon = document.createElement("i");
icon.classList.add("el-icon-copy-document");
button.appendChild(icon);
button.className = "copy-button";
const container = document.createElement("div");
container.className = "code-container";
container.appendChild(p);
container.appendChild(button);
code.parentNode.insertBefore(container, code);
container.appendChild(code);
code.classList.add("clipboard-bound");
// 创建包含language容器的div
const topcontainer = document.createElement("div");
topcontainer.className = "topcontainer";
container.appendChild(topcontainer);
topcontainer.appendChild(p);
topcontainer.appendChild(button);
//监听横向滚动
const bottomDiv = document.querySelector(".code-container");
bottomDiv.addEventListener("scroll", function () {
const topDiv = document.querySelector(".topcontainer");
topDiv.style.left = `${bottomDiv.scrollLeft}px`;
topDiv.style.right = `${-bottomDiv.scrollLeft}px`;
});