特效一 - - js实现文字一个一个显示

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div></div>
</body>
<script>
  let divEL = document.getElementsByTagName('div')[0]
  let text = 'we need love!'
  let index = 1
  let timer = null

  function showText() {
    divEL.innerText = text.slice(0, index)
    index++
    if (index >= text.length) {
      clearTimeout(timer)
    }
    timer = setTimeout(() => showText(), 500)
  }
  showText()
</script>

</html>

  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: <html> <head> <title>爱你一生一世</title> <style> body { background-image: url("love.jpg"); background-repeat: no-repeat; background-size: cover; font-family: Arial, sans-serif; font-size: 16px; line-height: 1.5; color: #333333; } .container { width: 500px; margin: auto; padding: 30px; background-color: #f3f3f3; border: 1px solid #cccccc; border-radius: 10px; box-shadow: 0 0 10px #cccccc; } .title { text-align: center; font-size: 24px; font-weight: bold; margin-bottom: 20px; } .content { text-align: center; font-size: 18px; line-height: 1.5; margin-bottom: 20px; } .button { text-align: center; margin-top: 20px; } a.btn { display: inline-block; padding: 10px 20px; background-color: #0099cc; color: #ffffff; text-decoration: none; border-radius: 5px; } a.btn:hover { background-color: #33aaff; } </style> </head> <body> <div class="container"> <div class="title">爱你一生一世</div> <div class="content"> 我爱你,无论你在哪里,我都会一直陪着你,永远不离开! </div> <div class="button"> <a href="javascript:;" class="btn">我也爱你</a> </div> </div> </body> </html> ### 回答2: 以下是一个简单的酷炫特效表白网页代码: ```html <!DOCTYPE html> <html> <head> <title>特效表白</title> <style> body { background-color: black; text-align: center; } h1 { color: white; font-size: 5em; letter-spacing: 0.2em; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); } .glow { color: white; text-shadow: 0 0 10px #00fff5, 0 0 20px #00fff5, 0 0 30px #00fff5, 0 0 40px #00fff5, 0 0 50px #00fff5, 0 0 60px #00fff5, 0 0 70px #00fff5; } </style> </head> <body> <h1 class="glow">我喜欢你!</h1> <script> const title = document.querySelector('h1'); const text = title.textContent; const splitText = text.split(""); title.textContent = ""; for (let i = 0; i < splitText.length; i++) { title.innerHTML += "<span>" + splitText[i] + "</span>"; } let char = 0; let timer = setInterval(onTick, 50); function onTick() { const span = title.querySelectorAll('span')[char]; span.classList.add('fade'); char++; if (char === splitText.length) { complete(); return; } }; function complete() { clearInterval(timer); timer = null; }; </script> </body> </html> ``` 这个网页使用了CSS和JavaScript实现特效。在黑色背景中央,一个白色的"h1"标题元素以酷炫的光晕效果展示出"我喜欢你!"的文字。这个特效通过CSS的"text-shadow"属性和JavaScript的定时器实现文字被拆分成一个个单独的母元素,通过定时器控制每个母元素的逐渐显示和淡出,从而形成光晕效果。 ### 回答3: 当然,以下是一个酷炫特效的表白网页代码。 ```html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>表白</title> <style> body { background-color: black; overflow: hidden; } #message { position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%); font-family: 'Arial', sans-serif; font-size: 40px; color: white; text-align: center; text-shadow: 0px 0px 30px #ff00ff; animation: blur 5s infinite; } @keyframes blur { 0% { filter: blur(0px); } 50% { filter: blur(10px); } 100% { filter: blur(0px); } } #firework { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); height: 300px; width: 300px; z-index: 1; animation: explode 2s infinite; } @keyframes explode { 0% { transform: scale(0); opacity: 0; } 50% { transform: scale(1); opacity: 1; } 100% { transform: scale(0); opacity: 0; } } </style> </head> <body> <div id="message"> 亲爱的,我喜欢你! </div> <div id="firework"> <img src="firework.gif" alt="firework"> </div> </body> </html> ``` 这个网页使用了HTML和CSS来创建一个酷炫的表白效果。首先,在页面的背景选择了黑色作为背景颜色,并设定为全屏显示。然后,在页面上方居中显示“亲爱的,我喜欢你!”这段表白的文字文字使用白色体,周围有粉色光晕特效文字还添加了模糊动画效果,让体在5秒内模糊和恢复,形成律动感。接着,页面中心出现一个宽高为300像素的“烟花”图像,使用了一个爆炸的动画效果,让图像逐渐放大并在2秒内消失。最后,添加了一个动画效果,通过循环展示表白的信息和烟花动画,增加戏剧性和酷炫感。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值