将dom元素与另一个固定顶部元素的底部对齐 [英] Align dom element to the bottom of another fixed-top element

查看:91
本文介绍了将dom元素与另一个固定顶部元素的底部对齐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个固定在屏幕顶部的div。在div中有一个搜索区域,您可以在其中进行ajax调用并将数据提取到div中,从而更改div高度。

另外还有一个名为ThingsToAlign的div。我想将它与固定顶部div的底部对齐。

任何人都知道如何做到这一点?我尝试过 vertical-align float:top 但他们都不工作..谢谢。

 < div className =container-fluid> 
< div className =navbar-fixed-top>
< SearchArea />
< / div>
< div>
< ThingsToAlign />
< / div>
< / div>

在bootstrap中,类navbar-fixed-top具有以下属性。

  .navbar-fixed-top {
position:fixed;
top:0;





ps:我在react.js中编写代码,所以这就是为什么你看到className 而不是class

解决方案

首先,您的HTML属性 className 是不正确的(在标准HTML中)。它应该是 class



其次,您应该尽量避免使用尖括号来环绕演示文本。浏览器会认为它是一个标签,并忽略它(即呈现时它将是不可见的)。

你的问题并不完全清楚,但是从我理解的这个演示可能会有所帮助: http://jsfiddle.net/kdbsm3hz/



否则,您可能会在其他类似问题中找到解决方案:


I have a div that is fixed to the top of the screen. In the div there is a search area where you make ajax calls and fetch data into the div, and that changes the div height.

Also there is another div called "ThingsToAlign". I want to align this to the bottom of the fixed-top div.

Any one knows how to do this? I tried vertical-align or float: top but none of them are working.. Thanks.

<div className="container-fluid">
    <div className="navbar-fixed-top">
      <SearchArea />
    </div>
    <div>
      <ThingsToAlign/>
    </div>
</div>

In bootstrap the class navbar-fixed-top has the following properties.

.navbar-fixed-top {
    position: fixed;
    top: 0;
}

p.s: I was coding in react.js so that's why you see "className" instead of "class"

解决方案

First, your HTML attribute className is incorrect (in standard HTML). It should be class.

Second, you should try to stay away from using angle brackets to surround demo text. The browser will consider it a tag and ignore it (i.e., it will be invisible when rendered).

Your question is not entirely clear to me, but from what I understand this demo may be helpful: http://jsfiddle.net/kdbsm3hz/

Otherwise, you may find a solution in other similar questions:

这篇关于将dom元素与另一个固定顶部元素的底部对齐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆