首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >聊天中的跳跃点

聊天中的跳跃点
EN

Stack Overflow用户
提问于 2022-06-13 17:18:23
回答 1查看 110关注 0票数 3

我现在正在构建一个基于网络的聊天机器人。作为聊天机器人的一部分,我实现了跳点,指示输入如下:

CSS文件

代码语言:javascript
复制
    .jumping-dots span {
      position: relative;
        margin-left: auto;
        margin-right: auto;
      animation: jump 1s infinite;
    }
    .jumping-dots .dot-1{
      background-color: #ED49FE;
            width:12px;
            height:12px;
            border-radius:50%;
            margin-right:3px;
            
      animation-delay: 200ms;
    }
    .jumping-dots .dot-2{
      background-color: #ED49FE;
            width:12px;
            height:12px;
            border-radius:50%;
            margin-right:3px;
      animation-delay: 400ms;
    }
    .jumping-dots .dot-3{
        background-color: #ED49FE;
                width:12px;
            height:12px;
            border-radius:50%;
            margin-right:3px;
      animation-delay: 600ms;
    }
    
    @keyframes jump {
      0%   {bottom: 0px;}
      20%  {bottom: 5px;}
      40%  {bottom: 0px;}
    }

HTML文件

代码语言:javascript
复制
<div class="my message">
<span class="jumping-dots">
  <span class="dot-1">.</span>
  <span class="dot-2">.</span>
  <span class="dot-3">.</span>
</span>
</div>

我的问题是,这些点在某种程度上没有正确显示,就像在下面的图像中所看到的那样(它们不是圆的,圆点内有一个黑点):

我的错误在哪里?

其次,我希望使用以下代码以编程方式删除这些点:

代码语言:javascript
复制
var insertedContent = document.querySelector(".jumping-dots");
if(insertedContent) {
    insertedContent.parentNode.removeChild(insertedContent);
}

不幸的是,这并不能消除一切(仍然有一小部分点还在)。为什么?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-06-13 17:31:50

点不是圆形的原因是因为默认情况下span元素被设置为内联显示。这意味着元素将只占用显示文本所需的空间。不能将宽度和高度设置为内联显示的元素。

尝试将.j唱点span类设置为内联块显示。这也将允许您从元素中移除句点,而不会使其消失。跳点的新代码如下:

代码语言:javascript
复制
.jumping-dots span {
  position: relative;
  margin-left: auto;
  margin-right: auto;
  animation: jump 1s infinite;
  display: inline-block;
}

.jumping-dots .dot-1 {
  background-color: #ED49FE;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 3px;
  animation-delay: 200ms;
}

.jumping-dots .dot-2 {
  background-color: #ED49FE;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 3px;
  animation-delay: 400ms;
}

.jumping-dots .dot-3 {
  background-color: #ED49FE;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 3px;
  animation-delay: 600ms;
}

@keyframes jump {
  0% {
    bottom: 0px;
  }
  20% {
    bottom: 5px;
  }
  40% {
    bottom: 0px;
  }
}
代码语言:javascript
复制
<div class="my message">
  <span class="jumping-dots">
  <span class="dot-1"></span>
  <span class="dot-2"></span>
  <span class="dot-3"></span>
  </span>
</div>

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72606726

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档