首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将文本放在css水平条形图之前和之后

将文本放在css水平条形图之前和之后
EN

Stack Overflow用户
提问于 2021-05-05 03:23:24
回答 1查看 42关注 0票数 2

这就是我想要做的。我有CSS水平条形图。问题是,我试图在前后获取一些文本。请看当前截图

代码语言:javascript
复制
.forecasting {
  box-sizing: border-box;
  width: 100%;
  margin: 20px 0;
}

.forecasting p {
  padding: 0;
  letter-spacing: 1px;
  margin: 0 0 15px;
  color: #000;
  font-weight: bold;
}

.forecasting p:nth-child(2) {
  float: right;
  position: relative;
  top: -25px;
}

.forecast-bar {
  box-sizing: border-box;
  background: #fff;
  border: #0000CD 1px;
  border-style: solid;
}

.forecast-todate {
  width: 100%;
  height: 15px;
  background: #0000CD;
}
代码语言:javascript
复制
<div class="forecasting">
  <p>Name of person $30,777,854.19</p>
  <p>$30,777,854.19</p>

  <div class="forecast-bar">
    <div class="forecast-todate" style="width: 90%;"></div>
  </div>
</div>

我怎么才能先得到文本,中间是条形图,最后才是文本。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-05-05 03:32:44

这就是你要找的吗?基本上,我已经将flexbox添加到您的主div中,以便将子元素放在一行中,并让align-items: center使它们水平居中

代码语言:javascript
复制
 .forecasting {
    box-sizing: border-box;
    width: 100%;
    display: flex;
    align-items: center;
 }

.forecasting p {
   padding: 0;
   letter-spacing: 1px;
   color: #000;
   font-weight: bold;
}

.forecast-bar {
    box-sizing: border-box;
    background: #fff;
    border: #0000CD 1px;
    border-style: solid;
    width: 80%;
    padding-right:20px;
    margin-right:10px;
}

.forecast-todate {
   width: 100%;
   height: 15px;
   background: #0000CD;
 }
代码语言:javascript
复制
 <div class="forecasting">
      <p>Name of person </p>

      <div class="forecast-bar" >
         <div class="forecast-todate" ></div>
      </div>
      <p>$30,777,854.19</p>
  </div>

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

https://stackoverflow.com/questions/67390929

复制
相关文章

相似问题

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