From d490e42ffe823173477b841ec397105bd06cb336 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Thu, 17 Jun 2021 13:35:36 -0400 Subject: rid of $samples iframes --- .../web/api/range/getboundingclientrect/index.html | 29 ++++++---------------- 1 file changed, 7 insertions(+), 22 deletions(-) (limited to 'files/zh-cn/web/api/range/getboundingclientrect') diff --git a/files/zh-cn/web/api/range/getboundingclientrect/index.html b/files/zh-cn/web/api/range/getboundingclientrect/index.html index 4c10f536b0..d49eb8c65c 100644 --- a/files/zh-cn/web/api/range/getboundingclientrect/index.html +++ b/files/zh-cn/web/api/range/getboundingclientrect/index.html @@ -22,16 +22,16 @@ translation_of: Web/API/Range/getBoundingClientRect
boundingRect = range.getBoundingClientRect()
 
-

示例

+

示例

HTML

-
<div id="highlight"></div>
+
<div id="highlight"></div>
 <p>This example positions a "highlight" rectangle behind the contents of a range. The range's content <b>starts here</b> and continues on until it <b>ends here</b>. The bounding client rectangle contains everything selected in the range.</p>

CSS

-
#highlight {
+
#highlight {
   background: yellow;
   position: absolute;
   z-index: -1;
@@ -43,7 +43,7 @@ p {
 
 

JavaScript

-
const range = document.createRange();
+
const range = document.createRange();
 range.setStartBefore(document.getElementsByTagName('b').item(0), 0);
 range.setEndAfter(document.getElementsByTagName('b').item(1), 0);
 
@@ -56,30 +56,15 @@ highlight.style.height = `${clientRect.height}px`;

结果

-

+

{{EmbedLiveSample("Example")}}

规范

- - - - - - - - - - - - - -
规范状态备注
{{SpecName('CSSOM View', '#dom-range-getboundingclientrect', 'Range.getBoundingClientRect()')}}{{Spec2('CSSOM View')}}Initial specification.
+{{Specifications}}

浏览器兼容性

- - -

{{Compat("api.Range.getBoundingClientRect")}}

+

{{Compat}}

参见

-- cgit v1.2.3-54-g00ecf