JavaScript DHTML/Style Layout/Bounding Client

Материал из Web эксперт
Версия от 07:28, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

Bounding Client Rect "bottom"

    
<html>
<body>
<p id="myP" style="background-color:black; color:white; width:200;">
This is some sample text.
</p>
<button onclick="alert(myP.getBoundingClientRect().bottom);">Bottom</button>
</body>
</html>



Bounding Client Rect "left" Example

    
<html>
<body>
<p id="myP" style="background-color:black; color:white; width:200;">
This is some sample text.
</p>
<button onclick="alert(myP.getBoundingClientRect().bottom);">Bottom</button>
<button onclick="alert(myP.getBoundingClientRect().top);">Top</button>
<button onclick="alert(myP.getBoundingClientRect().left);">Left</button>
<button onclick="alert(myP.getBoundingClientRect().right);">Right</button>
</body>
</html>



Bounding Client Rect "right" Example

    
<html>
<body>
<p id="myP" style="background-color:black; color:white; width:200;">
This is some sample text.
</p>
<button onclick="alert(myP.getBoundingClientRect().bottom);">Bottom</button>
<button onclick="alert(myP.getBoundingClientRect().top);">Top</button>
<button onclick="alert(myP.getBoundingClientRect().left);">Left</button>
<button onclick="alert(myP.getBoundingClientRect().right);">Right</button>
</body>
</html>



Bounding Client Rect "top" Example

    
<html>
<body>
<p id="myP" style="background-color:black; color:white; width:200;">
This is some sample text.
</p>
<button onclick="alert(myP.getBoundingClientRect().bottom);">Bottom</button>
<button onclick="alert(myP.getBoundingClientRect().top);">Top</button>
<button onclick="alert(myP.getBoundingClientRect().left);">Left</button>
<button onclick="alert(myP.getBoundingClientRect().right);">Right</button>
</body>
</html>