如何使用CSS仅定位浏览器视口顶部的元素? [英] How to position an element just off the top of the browser viewport using only css?
本文介绍了如何使用CSS仅定位浏览器视口顶部的元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想要一个绝对定位的元素刚刚离开浏览器窗口 - 就在浏览器视口顶部。请注意,我无法提供指定元素的确切高度。
I want an absolutely-positioned element to be just out of the browser window - just off the top of the browser viewport. Note that I cannot provide an exact height of the specified element.
可以这样做吗?
推荐答案
CSS b
#theElement {
position: fixed;
bottom: 100%;
}
jQuery: b
var $el = $('#theElement');
$el.css({
position: 'fixed',
top: '-' + $el.outerHeight()
});
这篇关于如何使用CSS仅定位浏览器视口顶部的元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文