Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. Element
  4. clientTop

Element: clientTop property

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨July 2015⁩.

TheclientTop read-only property of theElement interface returns the width of the top border of an element in pixels.

All that lies between theoffsetTop andclientTop is the element's border. This is because theoffsetTop indicates the location of the top of the border (not the margin) while the client area starts immediately below the border, including padding. Therefore, theclientTop value is always equal to theborder-top-width, rounded to integer. For example, if the computedborder-top-width is zero, thenclientTop is also zero.

Value

An integer.

Examples

In the following example, the client area has a white background and a 24px blackborder-top. TheclientTop value is the distance from where the margin (yellow) area ends and the padding and content areas (white) begin: that is, 24px.

HTML

html
<div>  <div>    <p>      Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod      tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim      veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea      commodo consequat.    </p>  </div></div>

CSS

css
#container {  margin: 3rem;  background-color: rgb(255 255 204);  border: 4px dashed black;}#contained {  margin: 1rem;  border-top: 24px black solid;  padding: 0px 28px;  overflow: auto;  background-color: white;}

Result

Specifications

Specification
CSSOM View Module
# dom-element-clienttop

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp