diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/resizeobserverentry | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/zh-cn/web/api/resizeobserverentry')
-rw-r--r-- | files/zh-cn/web/api/resizeobserverentry/index.html | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/resizeobserverentry/index.html b/files/zh-cn/web/api/resizeobserverentry/index.html new file mode 100644 index 0000000000..e3aa5fede9 --- /dev/null +++ b/files/zh-cn/web/api/resizeobserverentry/index.html @@ -0,0 +1,60 @@ +--- +title: ResizeObserverEntry +slug: Web/API/ResizeObserverEntry +translation_of: Web/API/ResizeObserverEntry +--- +<div>{{APIRef("Resize Observer API")}}{{SeeCompatTable}}</div> + +<p class="summary"><strong><code>ResizeObserverEntry</code></strong> 接口是传递给{{domxref('ResizeObserver.ResizeObserver','ResizeObserver()')}} 构造器回调函数中的参数对象。</p> + +<h2 id="属性">属性</h2> + +<dl> + <dt>{{domxref('ResizeObserverEntry.contentRect')}} {{experimental_inline}} {{readonlyinline}}</dt> + <dd>对改变尺寸大小的元素的 {{domxref('DOMRectReadOnly')}}引用(包含x,y,width,height,top,right,bottom,left属性)。</dd> + <dt>{{domxref('ResizeObserverEntry.target')}} {{experimental_inline}} {{readonlyinline}}</dt> + <dd>当前改变尺寸大小的元素的 {{domxref('Element')}} 引用</dd> + <dt> </dt> +</dl> + +<h3 id="事件">事件</h3> + +<p>无</p> + +<h2 id="方法">方法</h2> + +<p>无.</p> + +<h2 id="示例">示例</h2> + +<p>以下示例通过观察box的宽度变化从而改变其边框圆角半径。</p> + +<pre class="brush: js">const resizeOserver = new ResizeObserver(entries => { + for (let entry of entries) { + entry.target.style.borderRadius = Math.max(0, 250 - entry.contentRect.width) + 'px'; + } +}); +resizeObserver.observe(document.querySelector('.box:nth-child(2)'));</pre> + +<h2 id="规范">规范</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">Specification</th> + <th scope="col">Status</th> + <th scope="col">Comment</th> + </tr> + <tr> + <td>{{SpecName('Resize Observer','#resize-observer-entry-interface','ResizeObserverEntry')}}</td> + <td>{{Spec2('Resize Observer')}}</td> + <td>Initial definition.</td> + </tr> + </tbody> +</table> + +<h2 id="浏览器兼容性">浏览器兼容性</h2> + + + +<p>{{Compat("api.ResizeObserverEntry")}}</p> |