位置: IT常识 - 正文

分享一个CSS的垂帘效果(css垂直导航栏)

编辑:rootadmin
分享一个CSS的垂帘效果

推荐整理分享分享一个CSS的垂帘效果(css垂直导航栏),希望有所帮助,仅作参考,欢迎阅读内容。

分享一个CSS的垂帘效果(css垂直导航栏)

文章相关热门搜索词:css实现垂直居中的方法,css垂直定位,css垂直导航栏,css div垂直居中的几种方法,css设置垂直位移一半,css垂直定位,css垂直对齐方式怎么设置,css 垂直,内容如对您有帮助,希望把文章链接给更多的朋友!

先上效果图: 再上代码:

<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Title</title> <style> html, body, canvas { -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } html, body { width: 100%; height: 100%; overflow: hidden; margin: 0; display: flex; align-items: center; justify-content: center; background: #191919; } .asset-img { display: none; } </style></head><body><canvas></canvas><img class="asset-img" id="light-img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAAZCAMAAADzN3VRAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAACnVBMVEUAAAD40ED40D740Dv40En40Dr40FH40Df40D/40D340Dn40Dz40Dj40AD40Ff40Db40DT40EH40EL40ED40ED40Dv40D/4zz/4zz74zz/4zz/40D74zz/4zz/4zz/40UH40kD40UL40kH4zz/4zz340D34zz740kH41UT410f410j410j410f40D/40D/4zz/40ED40EH400T410f42Er4103410/411D41UT40kH40D/4z0D4zz/41UX410j42E7411L42Ff42Vv42Vz42En41kb40UH4zz/40Dz40ED41UT42Ej4107411b42l743WT432r4323432r410/42En4zz340Dn400H410f42mD432v44nf45IP45Yn45IT44nj432r411b400L40D/4zz/41UT42Er411P432v44oD46Zv47q/48Lj46Zr432n40UH410f42Ff44nf48r/499T4997499T48r744nf43WP40D741EH42Vv4+O34+PP4+O347q745IL432j40UD432345Yj48LX49934+PP4+Pj4993477T45Ib432z411D400D40D/40UH432n45IP47a7432j42Vv410/400H40Dr4zz340UD410b410346Zj48r343WP42Ff410f40D/41kT42Er42l744nv46Zf42l3411L410r41kX40ED410f42E7411b421/45IL45Ib432n421740UH40D340Dz4zz741EP410j410743WT432f432v43mj43GT42Ej41kT4zz740ED41EX411P42Ff42Fv411f410j41kX400P41034107411D42E340D740UH410j41kb41ET400H40D/40ED4z0D4zz74zz340D////+WdN8lAAAA3nRSTlMAAAAAAAAAAAAAAAAAAAAAAAAAAgMCBAcJDAkDCA0SFRsbGxMDBQscJSwwMS0SDAUFFyExQExUVyIYDQULJzlOZHeDhDonFwoDASE5VXGNpbO4tFM5BwEcMJa3zdjb2Mu2cBwDESM+Y7bU4ebo4bUUK3bL6vDy7+rKogIZgPb49ebXsBu02+jx9/jw6Nu0VRsBGbDX5q9/UhkCCRUqS+HqoHMqESI9i9Thi2E9IhEvTG+V1tq0kxsDAQchN1Ggr7SvoDghChUjYXJ/cjgnIUlSVEkFGi8qIhsFFAcICAaJi/ApAAAAAWJLR0Te6W7imwAAAAd0SU1FB+YMHBEUINvSacMAAAIKSURBVCjPY2AgBBgZmZiFRYQZgQBVnEVUTFxCUlJSSlxMlAVJjplVWkZWTl5BUUleWVZGhZkZYZKqmpy6hqaWtpaOhrqunj7MREZGA1lDI2MTUzNzM1MTYwtLK2uIFCOjiI2hrZ29g6OTs5Ojg72Lq5u7Bxs7SMZTXNfL28fXzz8gMMjfzzc4xEI3NIwVrEUyPMLeNzIqOiY2Lj4hMtE+Ikk2mYkRKCOekpqW7peRmZWdk52bmeeXnqYhJ84BkpHKLzAt9C/KKi4pLSvPragsNNXMl/JkZGCqUqvWMqsJiMkuqa2rL2tobKox06qWTOZg4EiWbNY2d25pbWvv6Ozo6u7pde7T6pf04GTgmGAzEahn0uSGsvqO+rIpjVOnTdeaoTaTmYGLfdbsOXMLKyvmzS/rKps/r2jBwrmL5KWAfmViEl+8ZGn6srzlK6Z0T1mxPG/lqtVr1oLdxp0sqbRu/YaNeUWbNm8q2rJ1w/p12yS38wDDh3PHTrldu/dsWLZ33/4DB5dt2HPosO7OMFBwM/KKHjl6bPf64yemOZ88dXz96TPyR6T5+EFByi6ganP07LrV585fmH5x6bqzs21UmZhg0XDJXe7ykjnrtK5cvXZdzv0GMycs6jiZpXdKLs532+Z2M0VSXAQ5KTAKeorcuu1uc+TO3e07hNDSCCMjNyczKz8nN8FkxgAAgH2hXtQzzA4AAAAldEVYdGRhdGU6Y3JlYXRlADIwMjItMTItMjhUMTc6MjA6MzIrMDA6MDA1MNVoAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDIyLTEyLTI4VDE3OjIwOjMyKzAwOjAwRG1t1AAAAABJRU5ErkJggg==" alt="base64"></body><script> class Mouse { constructor(canvas) { this.pos = new Vector(-1000, -1000) this.radius = 40 canvas.onmousemove = e => this.pos.setXY(e.clientX, e.clientY) canvas.ontouchmove = e => this.pos.setXY(e.touches[0].clientX, e.touches[0].clientY) canvas.ontouchcancel = () => this.pos.setXY(-1000, -1000) canvas.ontouchend = () => this.pos.setXY(-1000, -1000) } } class Dot { constructor(x, y) { this.pos = new Vector(x, y) this.oldPos = new Vector(x, y) this.friction = 0.97 this.gravity = new Vector(0, 0.6) this.mass = 1 this.pinned = false this.lightImg = document.querySelector('#light-img') this.lightSize = 15 } update(mouse) { if (this.pinned) return let vel = Vector.sub(this.pos, this.oldPos) this.oldPos.setXY(this.pos.x, this.pos.y) vel.mult(this.friction) vel.add(this.gravity) let { x: dx, y: dy } = Vector.sub(mouse.pos, this.pos) const dist = Math.sqrt(dx * dx + dy * dy) const direction = new Vector(dx / dist, dy / dist) const force = Math.max((mouse.radius - dist) / mouse.radius, 0) if (force > 0.6) this.pos.setXY(mouse.pos.x, mouse.pos.y) else { this.pos.add(vel) this.pos.add(direction.mult(force)) } } drawLight(ctx) { ctx.drawImage( this.lightImg, this.pos.x - this.lightSize / 2, this.pos.y - this.lightSize / 2, this.lightSize, this.lightSize ) } draw(ctx) { ctx.fillStyle = '#aaa' ctx.fillRect(this.pos.x - this.mass, this.pos.y - this.mass, this.mass * 2, this.mass * 2) } } class Stick { constructor(p1, p2) { this.startPoint = p1 this.endPoint = p2 this.length = this.startPoint.pos.dist(this.endPoint.pos) this.tension = 0.3 } update() { const dx = this.endPoint.pos.x - this.startPoint.pos.x const dy = this.endPoint.pos.y - this.startPoint.pos.y const dist = Math.sqrt(dx * dx + dy * dy) const diff = (dist - this.length) / dist const offsetX = diff * dx * this.tension const offsetY = diff * dy * this.tension const m = this.startPoint.mass + this.endPoint.mass const m1 = this.endPoint.mass / m const m2 = this.startPoint.mass / m if (!this.startPoint.pinned) { this.startPoint.pos.x += offsetX * m1 this.startPoint.pos.y += offsetY * m1 } if (!this.endPoint.pinned) { this.endPoint.pos.x -= offsetX * m2 this.endPoint.pos.y -= offsetY * m2 } } draw(ctx) { ctx.beginPath() ctx.strokeStyle = '#999' ctx.moveTo(this.startPoint.pos.x, this.startPoint.pos.y) ctx.lineTo(this.endPoint.pos.x, this.endPoint.pos.y) ctx.stroke() ctx.closePath() } } class Rope { constructor(config) { this.x = config.x this.y = config.y this.segments = config.segments || 10 this.gap = config.gap || 15 this.color = config.color || 'gray' this.dots = [] this.sticks = [] this.iterations = 10 this.create() } pin(index) { this.dots[index].pinned = true } create() { for (let i = 0; i < this.segments; i++) { this.dots.push(new Dot(this.x, this.y + i * this.gap)) } for (let i = 0; i < this.segments - 1; i++) { this.sticks.push(new Stick(this.dots[i], this.dots[i + 1])) } } update(mouse) { this.dots.forEach(dot => { dot.update(mouse) }) for (let i = 0; i < this.iterations; i++) { this.sticks.forEach(stick => { stick.update() }) } } draw(ctx) { this.dots.forEach(dot => { dot.draw(ctx) }) this.sticks.forEach(stick => { stick.draw(ctx) }) this.dots[this.dots.length - 1].drawLight(ctx) } } class App { static width = innerWidth static height = innerHeight static dpr = devicePixelRatio > 1 ? 2 : 1 static interval = 1000 / 60 constructor() { this.canvas = document.querySelector('canvas') this.ctx = this.canvas.getContext('2d') this.mouse = new Mouse(this.canvas) this.resize() window.addEventListener('resize', this.resize.bind(this)) this.createRopes() } createRopes() { this.ropes = [] const TOTAL = App.width * 0.06 for (let i = 0; i < TOTAL + 1; i++) { const x = randomNumBetween(App.width * 0.3, App.width * 0.7) const y = 0 const gap = randomNumBetween(App.height * 0.05, App.height * 0.08) const segments = 10 const rope = new Rope({ x, y, gap, segments }) rope.pin(0) this.ropes.push(rope) } } resize() { App.width = innerWidth App.height = innerHeight this.canvas.style.width = '100%' this.canvas.style.height = '100%' this.canvas.width = App.width * App.dpr this.canvas.height = App.height * App.dpr this.ctx.scale(App.dpr, App.dpr) this.createRopes() } render() { let now, delta let then = Date.now() const frame = () => { requestAnimationFrame(frame) now = Date.now() delta = now - then if (delta < App.interval) return then = now - (delta % App.interval) this.ctx.clearRect(0, 0, App.width, App.height) // draw here this.ropes.forEach(rope => { rope.update(this.mouse) rope.draw(this.ctx) }) } requestAnimationFrame(frame) } } function randomNumBetween(min, max) { return Math.random() * (max - min) + min } window.addEventListener('load', () => { const app = new App() app.render() }) class Vector { constructor(x, y) { this.x = x || 0 this.y = y || 0 } static add(v1, v2) { return new Vector(v1.x + v2.x, v1.y + v2.y) } static sub(v1, v2) { return new Vector(v1.x - v2.x, v1.y - v2.y) } add(x, y) { if (arguments.length === 1) { this.x += x.x this.y += x.y } else if (arguments.length === 2) { this.x += x this.y += y } return this } sub(x, y) { if (arguments.length === 1) { this.x -= x.x this.y -= x.y } else if (arguments.length === 2) { this.x -= x this.y -= y } return this } mult(v) { if (typeof v === 'number') { this.x *= v this.y *= v } else { this.x *= v.x this.y *= v.y } return this } setXY(x, y) { this.x = x this.y = y return this } dist(v) { const dx = this.x - v.x const dy = this.y - v.y return Math.sqrt(dx * dx + dy * dy) } }</script></html>

代码直接粘贴到html页面就能使用,顺滑的不可言说

本文链接地址:https://www.jiuchutong.com/zhishi/296029.html 转载请保留说明!

上一篇:情感计算——多模态情感识别(情感计算的应用)

下一篇:element - - - - - 你不知道的loading使用方式

  • 不打扰好友的清粉(不打扰好友清理僵尸粉)

    不打扰好友的清粉(不打扰好友清理僵尸粉)

  • 苹果11屏幕下滑一半怎么办(苹果11屏幕下滑一半作用)

    苹果11屏幕下滑一半怎么办(苹果11屏幕下滑一半作用)

  • iphone充电显示有液体(iphone充电显示有液体,然后无反应)

    iphone充电显示有液体(iphone充电显示有液体,然后无反应)

  • 保持微型计算机正常运行必不可少的输入输出设备是(保持微型计算机正常运行必不可少的输出设备是)

    保持微型计算机正常运行必不可少的输入输出设备是(保持微型计算机正常运行必不可少的输出设备是)

  • 华为手机怎么防止骚扰电话(华为手机怎么防误触模式)

    华为手机怎么防止骚扰电话(华为手机怎么防误触模式)

  • 苹果6长度是几厘米(苹果6多少长度)

    苹果6长度是几厘米(苹果6多少长度)

  • 华为手机微信深夜模式怎么打开(华为手机微信深色模式)

    华为手机微信深夜模式怎么打开(华为手机微信深色模式)

  • 一加8pro防水级别(一加8pro的防水等级)

    一加8pro防水级别(一加8pro的防水等级)

  • qq消息免打扰什么意思(qq里消息免打扰)

    qq消息免打扰什么意思(qq里消息免打扰)

  • 手机ke是什么(手机壳是什么垃圾分类)

    手机ke是什么(手机壳是什么垃圾分类)

  • 8250u相当于台式机什么cpu(8250u和8250)

    8250u相当于台式机什么cpu(8250u和8250)

  • 奔腾g2020相当于i几(奔腾g2020相当于i3什么型号)

    奔腾g2020相当于i几(奔腾g2020相当于i3什么型号)

  • 苹果图片放大镜怎么弄(苹果图片放大镜在哪里)

    苹果图片放大镜怎么弄(苹果图片放大镜在哪里)

  • 如何把iphone数据导入新iphone(如何把iphone数据导入macbook)

    如何把iphone数据导入新iphone(如何把iphone数据导入macbook)

  • 豆豆趣玩如何绑定微信(豆豆趣玩怎么注册账号)

    豆豆趣玩如何绑定微信(豆豆趣玩怎么注册账号)

  • 手机怎么查银行卡的钱(手机怎么查银行卡号全部数字)

    手机怎么查银行卡的钱(手机怎么查银行卡号全部数字)

  • office怎么建目录(word2016建立目录)

    office怎么建目录(word2016建立目录)

  • 微信语音播报怎么申请(微信语音播报怎么设置)

    微信语音播报怎么申请(微信语音播报怎么设置)

  • 一加7pro有nfc吗(一加7t pro有nfc吗)

    一加7pro有nfc吗(一加7t pro有nfc吗)

  • 苹果5se什么时候出的(iphone5什么时候)

    苹果5se什么时候出的(iphone5什么时候)

  • 怎么阻止网络电话来电(怎么阻止网络电话打进来)

    怎么阻止网络电话来电(怎么阻止网络电话打进来)

  • 快手小店店铺保证金是多少(快手小店店铺保证金怎么退)

    快手小店店铺保证金是多少(快手小店店铺保证金怎么退)

  • pp视频怎么取消自动续费(pp视频怎么取消自动续费苹果)

    pp视频怎么取消自动续费(pp视频怎么取消自动续费苹果)

  • Linux- 系统随你玩之--文本处理三剑客--grep继任者sed(linux系统操作教程)

    Linux- 系统随你玩之--文本处理三剑客--grep继任者sed(linux系统操作教程)

  • 安装服务费税率是多少
  • 先收到发票还未付款怎么做账
  • 职工宿舍楼日常管理制度
  • 委托开发的软件产品即征即退
  • 进项发票不勾选会有什么后果
  • 技术服务发票怎么开 安全培训
  • 文化事业建设费征收对象
  • 个税申报汇总表怎么填写
  • 机器设备计提折旧年限是多少
  • 本年利润期末
  • 固定资产报废相关规定
  • 含税价什么意思?
  • 结转工资结算中各种代扣款项
  • 低值易耗品包括哪些内容?属于什么科目?
  • 建筑公司采购制度和流程
  • php文件可包含哪三部分代码
  • phpwind教程
  • Windows10屏幕键盘在哪
  • 如何才能显示效果更好
  • 将银行借款存入银行会引起企业资产总额的变化吗
  • 微信公众号实名认证怎么更改
  • 软件企业高新技术有哪些
  • 暴风雪的寒冷
  • form表单中自动提交表单的按钮类型是
  • 坏账损失的会计分录
  • 企业上交财政款分录
  • 如何用php做到页数显示
  • php数组降序排列
  • thinkphp6验证
  • 承兑汇票贴现会计分录怎么做
  • 广告宣传制作
  • 预缴税款表怎么打印出来
  • 怎么样确认
  • 商业承兑汇票贴现会计分录
  • 企业有什么税收
  • 错账调整分录
  • 事业单位会计准则与政府会计准则的区别
  • 可供出售金融资产属于什么科目
  • 个税返还手续费怎么做账
  • 小规模如何缴纳税款
  • 应收账款和应付账款属于什么科目
  • 进项税额转出的所有会计分录
  • 去年亏损今年盈利同比怎么算
  • 公司宿舍楼出租让我当甲方违法吗
  • 房产税税率采用比例税率按照房产余值计征的年税率为
  • 财务分析与财务管理的共同点
  • 备用金账目处理
  • 个人收到国外汇款后怎么办
  • 税务局退还的三险是什么
  • 农产品收购发票如何抵扣进项税
  • 增值税留抵退税最新政策
  • 企业哪些项目可以立项
  • 执行企业会计准则的非上市企业
  • 开销项负数的流程
  • 盘亏应该怎么处理
  • 债权人接受债务怎么处理
  • mysql事件id100
  • sqlserver 表分区工具
  • ubuntu 安装
  • 微软官方操作系统叫什么
  • mac dock栏不见了
  • win7总是弹出广告怎么办
  • win8 设置
  • javascript ajax的5种状态介绍
  • jquery密码验证
  • python上传文件到网站
  • jquery input checked
  • 飞机大战剧情102
  • easyui表格
  • 基于网络创新形成的大数据的最突出特征是什么?( )
  • unity3d 物理引擎
  • 面试java基础知识
  • android实现一个闹钟程序
  • 登录""增值税发票选择确认平台""时提示""打开设备
  • 广西的高速怎么一段收费一段不收费
  • 土地储备中心出让公告
  • 企业所得税可以抵扣吗
  • 大兴区地方税务局
  • 轮胎消费税的征收环节
  • 企业申报系统网址
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

    网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

    友情链接: 武汉网站建设