如何使div出现在用户屏幕的右下角?
问题描述:
我需要一个div才能出现在用户屏幕的右下角.这意味着,无论用户使用的是20英寸的显示器还是50英寸的显示器,div总是需要显示在最右下角.因此无法固定位置.
I need a div to appear at the exact bottom right of a user's screen. That means, whether the user has a 20 inch monitor or a 50 inch, the div always needs to show at the farthest bottom right. So the positioning can't be fixed.
我尝试过但失败了:
<style>
.floatBox { border: 1px solid red; width: 300px; height: 100px; position: absolute; float: right; margin-top: 100%; }
</style>
<div class="floatBox"></div><!-- floatBox -->
我有一种感觉只能用javascript(jQuery)来完成,无论哪种情况,任何人都有解决方案吗?
I have a feeling it can only be done with javascript (jQuery), in either case does anyone have a solution?
答
为什么不能使用固定定位?
why can't fixed positioning be used?
.floatBox {
position : fixed;
bottom : 0px;
right : 0px;
}