如何使div出现在用户屏幕的右下角? [英] How to make a div appear at the exact bottom right of a user's screen?

查看:47
本文介绍了如何使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;
}

这篇关于如何使div出现在用户屏幕的右下角?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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