通体背景与通体下划线的实现

23 阅读1分钟
<script type="text/javascript">
        // h获取节点
        function $$(dom) {
            return document.querySelector(dom)
        }
        // 通体背景
        function lineBg() {
            const lineHeight = 30
            let strxina = $$(".strxina")
            for (let h = 0; h < strxina.clientHeight; h += lineHeight) {
                // console.log(h)
                let divs = document.createElement('div')
                divs.className = "line11"
                divs.style.top = `${h+23.5}px`
                strxina.appendChild(divs)
            }
        }
        lineBg()
    </script>

内容盒子行高要设置为30px