|
|

楼主 |
发表于 2026-5-24 20:47
|
显示全部楼层
核心示例代码:
- <style>
- :root { --xx: 60px; }
- .ta-container { margin: 30px auto; width: 700px; height: 450px; border: 1px solid gray; background: linear-gradient(90deg, #ddd var(--xx), white var(--xx), white 0); padding: 0; position: relative; }
- .lnum { position: relative; margin: 0; padding: 0; color: #999; visibility: hidden; }
- .lnum:hover::before { color: red; }
- .lnum::before { position: absolute; content: attr(data-num); left: -5px; top: 0; width: calc(var(--xx) - 10px); height: 100%; text-align: right; cursor: pointer; padding: 0; box-sizing: border-box; visibility: visible; }
- .hlight { color: red; }
- .tMid { text-align: center; }
- #editor { position: absolute; left: var(--xx); width: calc(100% - var(--xx)); height: 100%; box-sizing: border-box; padding: 8px; font-size: 18px; line-height: 25px; background: #fff; border: none; outline: none; resize: none; }
- #btnPrev { padding: 2px 8px; cursor: pointer; border: 1px solid #efe; border-radius: 4px; box-shadow:2px 2px 6px rgba(0,0,0,.25); font-size: 14px; }
- </style>
- <h1 class="tMid">Mahei Textarea编辑器示范</h1>
- <div class="ta-container">
- <textarea id="editor" placeholder="输入内容 ..."></textarea>
- </div>
- <div class="tMid"><button type="button" id="btnPrev" title="预览效果">运行代码</button></div>
- <script src="https://638183.freep.cn/638183/web/js/mhta.js"></script>
- <script>
- const ta = new TA(editor);
- btnPrev.onclick = () => ta.preView();
- </script>
复制代码
|
|