我对flex box还很陌生,我想知道是否有一种方法可以让我在同一列中首先有两个div/span,并且在它们之间有一个足够的空间.

End goal enter image description here

我目前拥有:

Current Progress without Text Count

使用文本计数:

With Text Count

HTML:

 <div class="emoji-text-container">
        <textarea type="text" class="text-area form-control" maxlength="279" formControlName="twitterText">
        </textarea>
        <button #toggleEmojiTwitter class="emoji-button mt-2 mr-2" type="button" (click)="_isTwitterEmojiPickerVisible = !_isTwitterEmojiPickerVisible"><mdb-icon class="emoji-icon" far icon="smile"></mdb-icon></button>
        <span class="text-count" [hidden]="_isTwitterEmojiPickerVisible">
          <span>{{_twitterCharLimit - this._postsForm.get('twitterText').value.length}}</span>
        </span>
 </div>

CSS:

//Emoji and Text Count

.emoji-container,
.emoji-text-container {
  display: flex;
  justify-content: center;
  align-items: start;
  margin: auto;
  border: 1px solid #d9d7d8;
}

.text-area {
  min-height: 15rem;
  border: 0;
  resize: none;
  outline: none;
  border: none;
  -webkit-box-shadow: none;
  -moz-box-shadow: none;
  box-shadow: none;
}

.emoji-button {
  border-radius: 25px;
  width: 45px;
  height: 30px;
  border: 1px solid #c8c8c8;
  font-size: 20px;
  background: transparent;
  cursor: pointer;

  &:focus {
    outline: 0;
  }
}

.emoji-icon {
  color: #9a9696;
}

.text-count {
  font-size: 14px;
  border-radius: 25px;
  background-color: #f4f2f2;
  width: 3rem;
  height: 12%;
  padding-top: 4px;
  font-weight: bold;
  color: #8e8d8d;
  border: 1px solid #c8c8c8;
  text-align: center;
}

推荐答案

最简单的设置是将你的笑脸和计数元素包装在额外的flex包装中,如下所示:

.container {
  display: flex;
}

.textarea {
   height: 100px;
}

.sidebar {
  display: flex;
  justify-content: space-between;
  flex-direction: column;
}
<div class="container">
  <textarea class="textarea"></textarea>
  <div class="sidebar">
    <div class="smile">????</div>
    <div class="text">12</div>
  </div>
</div>

Html相关问答推荐

传单自定义标记(divIcon)html/css不适用

Chrome中是否有一个本地显示密码功能,用于`input type = password/`?""<"">

CSS复选框并排

Angular /HTML5不会播放本地文件夹中的音频mpeg

为什么我的网页底部是蓝色背景而不是渐变色?

Div内容防止同级大小增加

单独处理Button:Focus的多行按钮

来自元标记的响应文本

如何防止弹性项目溢出容器?

当底部进入视图时从底部粘性定位

如何使用CSS Select 表亲元素

拨动switch 在重新加载时未重置

从垫分页器中删除输入边框

两个span,一个在div居中,好像没有另一个,另一个在右边