使用Bootstrap输入不会保留在父容器中

剧院数据分析员

我正在尝试做的是创建一个div包含标题和输入字段容器。我已经完成了此操作,但是由于某种原因,我无法将输入保存在父容器中。理想情况下,我希望它可以根据其容器的大小进行缩放。我希望标题和输入始终是容器内的容器。因此,这两个元素后面应始终带有灰色背景。在这里有一个jsFiddle 我将不胜感激。谢谢!

<div class="front-page-container-search">
    <h3>This is the text I will have in my bubble. Yet when I shrink my screen the input moves down. </h3>
    <form>
      <div class="input-group">
        <input type="text" class="form-control" placeholder="Find artist...">
        <span class="input-group-btn">
          <button class="btn btn-default" type="submit">
            <span class="glyphicon glyphicon-search"></span>
          </button>
        </span>
      </div>
    </form>
  </div>



.front-page-container-search {
    position: absolute;
    left: 10%;
    right: 10%;
    height: 100px;
    color: white;
    text-align: center;
    top: 100px;
    background-color: rgba(0, 0, 0, 0.6);
    border: 1px solid black;
    border-radius: 18PX;
    padding: 15px;
}
桑顿

在这种情况下,您所需要做的就是删除,height并让容器采用内容的默认高度。指定固定高度不会为您提供响应速度,并且当屏幕尺寸较小或调整大小时,内容将被强制占用有限的高度。让布局引擎根据内容为您计算高度,以确保所有内容都在父级中呈现。

.front-page-container-search {
    position: absolute;
    left: 10%;
    right: 10%;
    color: white;
    text-align: center;
    top: 100px;
    background-color: rgba(0, 0, 0, 0.6);
    border: 1px solid black;
    border-radius: 18PX;
    padding: 15px;
    
}
<div class="front-page-container-search">
    <h3>This is the text I will have in my bubble. Yet when I shrink my 
         screen the input moves down. </h3>
    <form>
      <div class="input-group myform">
        <input type="text" class="form-control" placeholder="Find artist...">
        <span class="input-group-btn">
          <button class="btn btn-default" type="submit">
            <span class="glyphicon glyphicon-search">Search</span>
          </button>
        </span>
      </div>
    </form>
  </div>

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

将工具提示保留在父容器中

Bootstrap表单字段不会保留在div中

为什么这条轻微的红线保留在父容器中?

在Bootstrap中使用push和pull类时,如何将内容保留在容器中?

如何使用flexbox将所有元素保留在容器中?

如何将动画div保留在容器中

如何使用角度ng-view将内容保留在输入字段中

值保留在输入中,而没有值标签

将输入顺序保留在嵌套字典中

如何从用户输入并保留在数组列表中

将内容保留在Twitter Bootstrap面板中

如何在运行时将JPanel保留在父容器的顶部?

使用键/值继承,但将其保留在pyyaml中

使用XPath将元素保留在文本中

当将MongoDB与Docker卷一起使用时,数据不会保留在数据库中吗?

OpenWeather Api将JavaScript提取与用户输入配合使用,将以前的数据保留在HTML页面中

如何从其子活动中获取父活动的价值并将其保留在android中?

为什么页脚中的图像不保留在容器中?

双向映射空值保留在子级的父级引用列中

为什么成员函数名称查找保留在父类中?

如何删除父元素,但将其子元素保留在 Thymeleaf 中?

父脚本调用子脚本:如果退出,如何保留在子脚本中设置的变量?

ConstraintLayout:当文本展开时保留在父级中的复合ImageView

python-从子级调用父方法时保留在基类中

经过测试后,Chrome进程仍保留在Docker容器中的Laravel Dusk

悬停CSS无法正常工作,并且容器元素保留在白色背景中

希望捕获图像保留在颤振应用程序的容器中

将用户保留在 TEdit 中

保留在python,pandas中