当前位置: 首页 > backend >正文

纯CSS实现自动滚动到底部

 

<!DOCTYPE html>
<html lang="zh-CN"><head><meta charset="UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>自动滚动到底部</title><style>* {box-sizing: border-box;}body {margin: 0;height: 100vh;display: flex;flex-direction: column;}.chater {flex: 1;overflow: auto;padding: 1em;display: flex;flex-direction: column-reverse;}.msger {flex: 1;display: flex;flex-direction: column;}.msger > pre {background-color: #eee;padding: 1em;border-radius: 8px;white-space: pre-wrap;}.msger .user {align-self: flex-end;margin-left: 10vw;}.msger .ai {align-self: flex-start;margin-right: 10vw;}.sender {flex-shrink: 0;padding: 1em;}</style></head><body><div class="chater"><div class="msger"></div></div><div class="sender"><input type="text" /><button onclick="send()">发送</button></div><script>function send() {document.querySelector('.chater').scrollTop = document.querySelector('.chater').scrollHeightconst pre = document.createElement('pre')pre.className = 'user'pre.textContent = document.querySelector('input').valuedocument.querySelector('.msger').appendChild(pre)const pre2 = document.createElement('pre')pre2.className = 'ai'const timer = setInterval(() => {pre2.textContent +=String.fromCharCode(Math.floor(Math.random() * 122) + 65).repeat(Math.ceil(Math.random() * 10)) + (Math.random() < 0.2 ? '\n' : ' ')if (pre2.textContent.length > 1000) clearInterval(timer)}, 50)document.querySelector('.msger').appendChild(pre2)}</script></body>
</html>

http://www.xdnf.cn/news/157.html

相关文章:

  • Redis面试——缓存淘汰和过期删除
  • CSS伪元素
  • Python 之 Faker 测试数据生成
  • uniapp中uni-easyinput 使用@input 不改变绑定的值
  • Linux中的管道
  • EDID结构
  • zookeeper启动报错have small server identifier
  • 3.8/Q1,GBD数据库最新文章解读
  • ApiHug 前端解决方案 - M1 内侧
  • Kafka安全认证技术:SASL/SCRAM-ACL方案详解
  • Ubuntu双保险改时区!北京/上海时区一键切换+手动硬核方案,运维大佬私藏秘籍泄露!
  • vue3 传参 传入变量名
  • chkconfig指令
  • Odoo:免费开源的轧制品行业管理软件
  • 计算机视觉cv2入门之车牌号码识别
  • Webview+Python:用HTML打造跨平台桌面应用的创新方案
  • [密码学实战]基于Python的国密算法与通用密码学工具箱
  • [密码学实战]国密算法面试题解析及应用
  • 苹果紧急修复两个已被利用的iOS漏洞,用于针对特定目标的复杂攻击
  • 基于亚博K210开发板——内存卡读写文件
  • 【AI模型学习】关于写论文——论文的审美
  • 微信小程序的全局变量(quanjubianliang)
  • ubuntu学习day3
  • Hexo+Github+gitee图床零成本搭建自己的专属博客
  • 团体程序设计天梯赛PTA-SHU冲刺赛4. L22-L32
  • .net core 项目快速接入Coze智能体-开箱即用-第2节
  • 【免登录ORACLE,jdk8安装包下载】jdk-8u441-windows-i586.exe和jdk-8u441-windows-x64.exe有什么区别
  • 前端为什么需要单元测试?
  • Python 项目文档编写全攻略:从入门到自动化维护
  • 自注意力机制self-attention