html - 将输入固定到页面底部

标签 html css

在过去的几个小时里,我一直在为这个问题绞尽脑汁。我正在尝试制作一个保留在页面底部的输入字段,类似于 Omegle 聊天栏。

Omegle chat bar I'm referencing

我已将高度设置为 100%(好吧,99,因为如果设置为 100,页面就会有不必要的滚动条)并将 CSS bottom 属性设置为 0,但无论我尝试什么,该栏都在页面下方 10% 左右浮动。

我的 CSS 代码是:

html {
height:99%;
width:99%;
}

input.chatbar {
bottom:0;
width:90%;
height:5%;

outline:none;
resize: none;

border:none;
border-bottom:#000 medium solid !important;
}

我的 HTML 代码是

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Global Chat</title>
</head>
<body>
  <input class="chatbar" />
</body>
</html>

here是它的一个 JSFiddle。

我希望它 float 在页面上方并随用户滚动,就像聊天栏一样。我该怎么做?

抱歉,我知道这是一个基本问题,但我在其他地方找不到答案。

最佳答案

添加 position: fixed; 到 css

还要注意百分比高度。查看min and max height properties

关于html - 将输入固定到页面底部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15081196/

相关文章:

css - Twitter Bootstrap - 连续设置超过 12 列的样式?

html - 在twilio mp3录制URL上进行范围请求时,将接受范围设置为无

html - 我怎么能做一个斜方肌div

javascript - 如何将除所选编辑器之外的所有 tinymce 编辑器设为标准

css - Firefox 顶部的奇怪空间

html - 模态关闭时 Bootstrap 蓝色轮廓

html - DIV 中的最大高度

html - 响应式设计

html - 同时水平和垂直排列<li>

css - 字体 - 生成的字体在 ie 中不起作用?