html - 聊天网络应用 : flex-boxes inside div position:fixed

标签 html css flexbox

我有一个聊天网络应用程序,其底部栏包括:按钮、文本输入、按钮:

<div id="bottom-bar">
  <div class="button-left">
    <img src="https://placeholdit.co//i/40x40">
  </div>
  <div class="textentry">
    <input type="text" id="chatmsg" name="chatmsg">
  </div>
  <div class="button-right">
    <img src="https://placeholdit.co//i/40x40">
  </div>
</div>

#bottom-bar {
    position: fixed;
    bottom: 0px;
    height: 40px;
    width: 100%;
}

我想要实现的目标:(1) 将左按钮放在底部栏的左侧,(2) 将右侧按钮放在底部栏的右侧,(3) 有一个可拉伸(stretch)的输入字段在中间使用所有可用空间。

我试过:

#bottom-bar {
   ...the css above and additionally ...
   display: flex;
   flex-direction: row;
   flex-wrap: nowrap;
   justify-content:space-between;
   align-items: center;
}

#chatmsg{
  width: auto;
}

但这让我无处可去。非常感谢任何帮助。

最佳答案

textentry 必须增长并占据所有剩余位置:

#bottom-bar {
    position: fixed;
    bottom: 0px;
    height: 40px;
    width: 100%;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content:space-between;
    align-items: center;
}
.button-left,
.button-right {
  width: 40px;
}
.textentry{
  flex-grow: 1;
}
#chatmsg {
  width: 100%;
}

检查这个:https://jsfiddle.net/43Lqzznt/3/

关于html - 聊天网络应用 : flex-boxes inside div position:fixed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47721436/

相关文章:

c# - 如何将两个表格放在一起?

html - 如何使用 CSS flexbox 架构设置文本组件的样式?

css - 如何基于flex或grid设置动态网格

html - 计算图像的纵横比以获得与 flexbox 相同的高度

javascript - 使用 Azure 媒体服务直播单个/静态音频文件

html - 如何在 objective-c 中创建 html 文件?

html - ng-repeat 创建一个多嵌套表

css - 页脚菜单栏的代码

jQuery-使某个图像类不受延迟加载的影响

html - Tumblr 主题侧边栏和无限滚动?