范围从像素 [英] Range from pixels

查看:103
本文介绍了范围从像素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有一个范围,我可以通过 getBoundingClientRect 获取其边框矩形。是相反的可能吗?也就是说,给定一个像素矩形创建一个范围。

If I have a Range, I can get its bounding rectangle via getBoundingClientRect. Is the reverse possible? That is, given a rectangle of pixels create a Range.

推荐答案

最近我做了选择。在支持Range的浏览器中,它创建一个范围,然后选择它,所以删除选择内容将是微不足道的。

I've done this recently for selections. In browsers that support Range, it creates a range and then selects it, so it would be trivial to strip out the selection stuff.

从FF和Google Chrome的像素坐标中选择

这篇关于范围从像素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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