html - 为什么元素会超出边界固定 div?

标签 html css

在我的应用程序中,我有一个固定的页脚,在这个里面我想在左边有一个输入文本框,在右边有一个按钮。

我的 htmlLESS 是:

.button {
  background: #3498db;
  background-image: -webkit-linear-gradient(top, #3498db, #2980b9);
  background-image: -moz-linear-gradient(top, #3498db, #2980b9);
  background-image: -ms-linear-gradient(top, #3498db, #2980b9);
  background-image: -o-linear-gradient(top, #3498db, #2980b9);
  background-image: linear-gradient(to bottom, #3498db, #2980b9);
  font-family: Arial;
  color: #ffffff;
  font-size: 20px;
  padding: 10px 20px 10px 20px;
  border: solid #1f628d 0px;
  text-decoration: none;
}

#totalPoints {
  position: fixed;
  left: 0px;
  bottom: 0px;
  height: 60px;
  width: 100%;
  margin: 0 20px 0.5em 20px;
  background: #fff;
}

input {
  width: 30%;
  float: left;
}

.button {
  float: right;
}
<div id="totalPoints">
  <input type="text" value.two-way="totalPoints" readonly>
  <button class="button">Test</button>
</div>

Sticky footer

I am expecting the button on the right to be within the confines of the div, but it is pushing outside the div.

有人知道为什么吗?

最佳答案

#totalPoints 的余量使其超出范围...

#totalPoints {
        position:fixed;
        left:0;
        bottom:0;
        height:60px;
        width:100%;
        margin: 0 0px 0px 0px; 
        background:#fff;
}

关于html - 为什么元素会超出边界固定 div?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47950658/

相关文章:

html - 等于基于另一个属性的 CSS 属性的值

jquery - 如何在 Blogger 中将帖子 iframe 移到帖子正文之外?

html - 无法打印整个 div,包括(X 符号开头的一些删除按钮和同一行中的文件名等)

javascript - 随机javascript div选择

html - 语义用户界面 : Get clearing segment to expand to the height of it's contents

jquery - 当菜单在 Bootstrap 中折叠时删除类

html - 需要在 &lt;textarea&gt; &lt;input type ="text"> 中调整 Bootstrap 图标

javascript - Google Maps API 不在 DIV 标记内呈现

javascript - 如何创建固定标题(不是粘性标题),但内容在 JS 中位于标题后面?

html - 如何使全宽图像响应? (无缩放/拉伸(stretch))