同一行3类

发布于 2025-01-29 03:45:49 字数 1047 浏览 2 评论 0原文

我想根据下面的每个点的颜色提供解释。

整个页面是:

我的Spesific领域的HTML代码:

<div class="dot-expl">
      <div class ="dot dot-red">Ended</div>
      <div class ="dot dot-green">Running</div>
      <div class ="dot dot-yellow">Ready to start</div>
    </div>

我的整个CSS代码:

 .dot-expl{
    display: flex;
    align-items: center;
    overflow:visible;
  }
  
  .dot {
    height: 20px;
    width: 20px;
    border-radius: 50%;
    display: inline-block;
  }
  .dot-red {
    background-color: red;
  }
  .dot-green {
    background-color: green;
  }
  .dot-yellow {
    background-color: yellow;
  }

但结果是:

我找不到如何在点之间提供更多空间,因为可以看到文本

I want to give an explanation based on color of each dot below.

The whole page is:
enter image description here

My HTML code for the spesific area:

<div class="dot-expl">
      <div class ="dot dot-red">Ended</div>
      <div class ="dot dot-green">Running</div>
      <div class ="dot dot-yellow">Ready to start</div>
    </div>

My whole CSS code:

 .dot-expl{
    display: flex;
    align-items: center;
    overflow:visible;
  }
  
  .dot {
    height: 20px;
    width: 20px;
    border-radius: 50%;
    display: inline-block;
  }
  .dot-red {
    background-color: red;
  }
  .dot-green {
    background-color: green;
  }
  .dot-yellow {
    background-color: yellow;
  }

But the result is:
enter image description here

I cannot find how to give more space between the dots as so as the text can be visible

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

海风掠过北极光 2025-02-05 03:45:49

您可以通过使用pseudo class ::
使用这种方法来完成此方法
我为每个dot设置了一个边距(左)(左),以在单个元素之间具有一定的空间。
您还可以给包装器一个固定宽度,并在包装​​器上使用josify-content。但是我认为这会让您遇到其他问题,具体取决于文本的长度。

.dot-expl {
  display: flex;
  align-items: center;
  overflow: visible;
}

.dot {
  margin: 0 5px;
  display: flex;
  align-items: center;
}

.dot::before {
  content: '';
  height: 20px;
  width: 20px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 2px;
}

.dot-red::before {
  background: red;
}

.dot-green::before {
  background: green;
}

.dot-yellow::before {
  background: yellow;
}
<div class="dot-expl">
  <div class="dot dot-red">Ended</div>
  <div class="dot dot-green">Running</div>
  <div class="dot dot-yellow">Ready to start</div>
</div>

You could do it with this approach by using the pseudo class ::before
I set a margin to each .dot on both sides (left & right) to have some space between the individual elements.
You could also give your wrapper a fixed width and use justify-content on the wrapper. But I assume this will make you run into other problems depending on the length of the text.

.dot-expl {
  display: flex;
  align-items: center;
  overflow: visible;
}

.dot {
  margin: 0 5px;
  display: flex;
  align-items: center;
}

.dot::before {
  content: '';
  height: 20px;
  width: 20px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 2px;
}

.dot-red::before {
  background: red;
}

.dot-green::before {
  background: green;
}

.dot-yellow::before {
  background: yellow;
}
<div class="dot-expl">
  <div class="dot dot-red">Ended</div>
  <div class="dot dot-green">Running</div>
  <div class="dot dot-yellow">Ready to start</div>
</div>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文